var i=1;
var j=1;

function changeTypeToPass(obj)
{
if(obj.value=="password")
document.getElementById('pass_td').innerHTML="<input type='password' style='text-align:left;font-size:10pt;padding-top:3px;' onBlur='changeTypeToText(this);' id='log_pass1' class='login_inputs' value='' />";
setTimeout(function() { document.getElementById('log_pass1').focus(); }, 50);
}

function changeTypeToText(obj)
{
if(obj.value=="")
document.getElementById('pass_td').innerHTML="<input type='text' style='text-align:center;font-size:10pt;padding-top:3px;' onClick='changeTypeToPass(this);' id='log_pass1' class='login_inputs' value='password' />";
}

function changeNews()
{
if((document.getElementById("changing_news")==null)||(document.getElementById("changing_news1")==null)) return;
if(news[i]!=undefined){
document.getElementById("changing_news").innerHTML=news[i];
i++;
if(i==news.length) i=0;
}

if(news1[j]!=undefined){
document.getElementById("changing_news1").innerHTML=news1[j];
j++;
if(j==news1.length) j=0;
}
}

function isNews()
{
if((document.getElementById("changing_news")!=null)&&(document.getElementById("changing_news1")!=null))
setInterval(changeNews,3000);
var IE='\v'=='v';
if((IE)||(navigator.userAgent.indexOf('Opera') > -1))
{document.getElementById("dutch_l").style.left="330px";
document.getElementById("english_l").style.left="338px";
}
if(navigator.userAgent.indexOf('Opera') > -1) 
{document.getElementById("menu").style.marginTop="-196px";
document.getElementById("switcher").style.top="-20px";}
else if(IE) 
{document.getElementById("menu").style.marginTop="-180px";
document.getElementById("switcher").style.top="-26px";}
}

function selectChange(obj)
{
name=obj.getAttribute("id")+'1';
if(obj.src.indexOf("unselected.png")!=-1) 
{
	if((obj.getAttribute("id")=="live_lite")&&(document.getElementById("live_pro1").value==1))
	{
		document.getElementById("live_pro").src="templates/images/unselected.png";
		document.getElementById("live_pro1").value=0;
	}
	else if((obj.getAttribute("id")=="live_pro")&&(document.getElementById("live_lite1").value==1))
	{
		document.getElementById("live_lite").src="templates/images/unselected.png";
		document.getElementById("live_lite1").value=0;
	}
		obj.src="templates/images/selected.png";
		document.getElementById(name).value=1;
}
else 
{
	obj.src="templates/images/unselected.png";
	document.getElementById(name).value=0;
}
}

function checkAllFields()
{
if(private_info.name_and_last.value=="") alert("Please enter your name");
else if(private_info.address.value=="") alert("Please enter your address");
else if(private_info.post_code.value=="") alert("Please enter your postal code");
else if(private_info.city.value=="") alert("Please enter your city");
else if(private_info.country.value=="") alert("Please enter your country");
else if(private_info.website.value=="") alert("Please enter your website");
else private_info.submit();
}

function checkAllFields1()
{
if(ch_info.client_name.value=="") alert("Please enter your name");
else if(ch_info.client_address.value=="") alert("Please enter your address");
else if(ch_info.client_post.value=="") alert("Please enter your postal code");
else if(ch_info.client_city.value=="") alert("Please enter your city");
else if(ch_info.client_country.value=="") alert("Please enter your country");
else if(ch_info.client_website.value=="") alert("Please enter your website");
else if((ch_info.new_pass.value!="")&&(ch_info.rep_pass.value=="")) alert("Please repeat password");
else if((ch_info.new_pass.value!="")&&(ch_info.rep_pass.value!="")&&(ch_info.rep_pass.value!=ch_info.new_pass.value)) alert("Repeated password is wrong. Please try again");
else if(ch_info.client_pass.value=="") alert("Please enter verification password");
else ch_info.submit();
}

function mouseOver(obj) {obj.style.backgroundImage="url(templates/images/button_hoover.png)";}
function mouseOut(obj) {obj.style.backgroundImage="url(templates/images/button_normal.png)";}

function showSubscribeMail()
{
str='<form name="subscribe_form" action="index.php" method="POST"><table width="100%" height="100%"><tr><td align="center" class="bottomsign">Please enter your e-mail:<br /><input style="width:200px;" type="text" name="subscribe_mail" id="subscribe_mail" /><br/><br/><input type="button" value="Submit" class="butt_style" onMouseOver="mouseOver(this);" onMouseOut="mouseOut(this);" onClick="checkMail();" />&nbsp;&nbsp;<input class="butt_style" type="button" value="Cancel" onMouseOver="mouseOver(this);" onMouseOut="mouseOut(this);" onClick="cancelButton();" /></td></tr></table></form>';
document.getElementById("news_info").innerHTML=str;
}

function cancelButton()
{
location.href='index.php';
}

function checkMail()
{
if(document.getElementById("subscribe_mail").value=="") alert("Please enter email where admin will send you newsletters");
else subscribe_form.submit();
}

function textCounter( field, countfield, maxlimit ) {
if ( field.value.length > maxlimit )
{
  field.value = field.value.substring( 0, maxlimit );
  alert( 'Short description can only be 120 characters in length.' );
  return false;
}
}

function showWhizzy(i)
{
document.getElementById('edit_content_'+i).style.display='';
document.getElementById('edit_color_'+i).style.display='none';
}

function hideWhizzy(i)
{
document.getElementById('edit_content_'+i).style.display='none';
document.getElementById('edit_color_'+i).style.display='';
}

function whizzywigResults(type_name,i)
{
syncTextarea();
document.getElementById(type_name+'_cont').innerHTML=document.getElementById('edited_'+i).value;
document.getElementById(type_name).value=document.getElementById(type_name+'_cont').innerHTML;
hideWhizzy(i);
}

function getElementHeight(id)
{
return document.getElementById(id).style.height;
}

function checkLoginFields()
{
if(document.getElementById('log_mail1').value=='email address') alert('Please enter email');
else if(document.getElementById('log_pass1').value=='password') alert('Please enter password');
else 
{
	document.getElementById('log_mail').value=document.getElementById('log_mail1').value;
	document.getElementById('log_pass').value=document.getElementById('log_pass1').value;
	document.login_form.submit();
}
}

function showBlocker(){
window.$.blockUI({ 
message: '<a style="color:#FFFFFF;font-family:Arial;font-size:19px;font-weight:bold;text-decoration:none;" href="account.php">Login as Administrator</a><br/><br/><a style="color:#FFFFFF;font-family:Arial;font-size:19px;font-weight:bold;text-decoration:none;" href="chat_admin/controlpanel/chat_operator.php">Login as operator</a>',
css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#000', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: .5, 
            color: '#fff' 
        } }); 
}
