function privacyPolicy(){
	var winwidth, winheight;
	winwidth=642;
	winheight=600;
	wposx=(screen.width-640 )/2;
	wposy=(screen.height-600 )/2;;
	file =  appUrl + '/privacy.php';
	popupWin = window.open(file, "iplotzprivacy", "status=no,resizable=no,toolbar=no,scrollbars=yes,screenX=" + wposx + ",screenY=0,left=" + wposx + ",top=" + wposy + ",width=" + winwidth + ",height=" + winheight);
	popupWin.focus();
}
function downloadLogo(){
	var winwidth, winheight;
	winwidth=642;
	winheight=400;
	wposx=(screen.width-640 )/2;
	wposy=(screen.height-400 )/2;;
	file =  appUrl + '/iplotzLogo.php';
	popupWin = window.open(file, "iplotzLogo", "status=no,resizable=no,toolbar=no,scrollbars=yes,screenX=" + wposx + ",screenY=0,left=" + wposx + ",top=" + wposy + ",width=" + winwidth + ",height=" + winheight);
	popupWin.focus();
}
function iplotzTerms(){
	var winwidth, winheight;
	winwidth=642;
	winheight=600;
	wposx=(screen.width-640 )/2;
	wposy=(screen.height-600 )/2;;
	file =  appUrl + '/terms.php';
	popupWin = window.open(file, "iplotzterms", "status=no,resizable=no,toolbar=no,scrollbars=yes,screenX=" + wposx + ",screenY=0,left=" + wposx + ",top=" + wposy + ",width=" + winwidth + ",height=" + winheight);
	popupWin.focus();
}
function videoTour(){
	var winwidth, winheight;
	var NS = false;
	try{
		NS = (navigator.appName=="Netscape")?true:false;
	}catch(e){
		
	}
	if(NS){
		winwidth=825;
		winheight=650;
		
	}else{
		winwidth=840;
		winheight=670;
	}	
	//winwidth=840;
	//winheight=670;
	wposx=(screen.width-820 )/2;
	wposy=(screen.height-650 )/2;;
	file =  appUrl + '/files/videotour/index.html';
	popupWin = window.open(file, "iplotzvideotour", "status=no,resizable=no,toolbar=no,scrollbars=yes,screenX=" + wposx + ",screenY=0,left=" + wposx + ",top=" + wposy + ",width=" + winwidth + ",height=" + winheight);
	popupWin.focus();
}
function vote(){
	var winwidth, winheight;
	var NS = false;
	try{
		NS = (navigator.appName=="Netscape")?true:false;
	}catch(e){
		
	}
	if(NS){
		winwidth=720;
		winheight=500;
		
	}else{
		winwidth=670;
		winheight=510;
	}
	winwidth=720;
	winheight=500;
	wposx=(screen.width-660 )/2;
	wposy=(screen.height-510 )/2;;
	file =  appUrl + '/vote.php';
	popupWin = window.open(file, "iplotzterms", "status=no,resizable=no,toolbar=no,scrollbars=yes,screenX=" + wposx + ",screenY=0,left=" + wposx + ",top=" + wposy + ",width=" + winwidth + ",height=" + winheight);
	popupWin.focus();
}


function showlargeImage(img){
	var winwidth, winheight;
	winwidth=1000;
	winheight=516;
	wposx=0;
	wposy=0;
	file =  appUrl + '/showlargeimage.php?img='+img;
	popupWin = window.open(file, "showcase", "status=no,resizable=no,toolbar=no,scrollbars=yes,screenX=" + wposx + ",screenY=0,left=" + wposx + ",top=" + wposy + ",width=" + winwidth + ",height=" + winheight);
	popupWin.focus();
}


function postBug(){
	var errorMessage = "";
	var comments = $('#comments').val();
	var postTitle = $('#postTitle').val();
	var iplotzType ="";
	$("input[@name='iplotzType']").each(function() { 
		if(this.checked){
			if( iplotzType !="" ) iplotzType +=", ";
			iplotzType += this.value;
		}
	});
	var operatingSystem = "";
	$("input[@name='operatingSystem']").each(function() { 
		if(this.checked){
			if( operatingSystem !="" ) operatingSystem +=", ";
			operatingSystem += this.value;
		}
	});
	var browserType = "";
	$("input[@name='browserType']").each(function() { 
		if(this.checked){
			if( browserType !="" ) browserType +=", ";
			browserType += this.value;
		}
	});
	var browserVersion  = $("#browserVersion").val();

	if( postTitle =="" ){
		errorMessage += "Please enter feedback title.";	
	}
	if( comments =="" ){
		errorMessage += "<br>Please enter feedback details.";	
	}
	if( iplotzType =="" ){
		errorMessage += "<br>Please choose iPlotz type.";	
	}	
	if(errorMessage !=""){
		$("#message").addClass("errormessage");
		$("#message").html(errorMessage);
		$("#message").show();
	}else{
		$("#ipType").val(iplotzType);
		$("#opSystem").val(operatingSystem);
		$("#brType").val(browserType);			
		document.frmBugreport.submit();
	}
}

function postForgot(){
	document.ResetPassword.submit();

}	
	
function postSupport(){

	var name = $('#name').val();
	var email = $('#email');
	var comments = $('#comments').val();
	var captchastring = $('#captchastring').val();
	var errorMessage = "";
	if( name =="" ){
		errorMessage = "<br>*Please enter your name.";
	}
	if( !isValidEmail(email) ){
		errorMessage += "<br>*Please enter valid email address.";	
	}
	if( comments =="" ){
		errorMessage += "<br>*Please enter your comments.";	
	}
	if( captchastring =="" ){
		errorMessage += "<br>*Please enter characters shown in picture.";	
	}	
	if( errorMessage !=""){
		$('#errorBoxMsg').html(errorMessage);	
		$('#errorBox').show();
	}else{
		document.frmSupport.submit();
	}
}
function isValidEmail(element){
	if(!(/(^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$)/i).test($(element).val())){
			return false;
	}	
	return true;
}

function postLogin(){
	$('#method').val("");
	var email = $('#email');
	var password = $('#password').val();
	var errorMessage = "";
	var errorMessage = "";
	if( !isValidEmail(email) ){
		errorMessage = "Please enter valid email/password.";	
	}
	if( password =="" ){
		errorMessage = "Please enter valid email/password.";
	}	
	if( errorMessage !=""){
		$('#errorBoxMsg').html(errorMessage);	
	}else{
		document.frmLogin.submit();
	}
}
function loginWin(){
	var email = $('#userEmail').val();	
	var plan = $('#plan').val();	
	file =  appUrl + '/login.php?email='+email+'&plan='+plan;
	location.href = file;
}

function toggleChanges(id){
	$('#releaseDetails_'+id).slideToggle("fast");
}



/************Avatar***************************/

function loadAvtarUpload() {
	if($("#pageLock").css("display") != 'block') {
	   lockPage();
	}
	$("#pageLock").html('');
	$("#avtarWindow").remove();
	$("body").append("<div id='avtarWindow'></div>");
	
	$.post(forumUrl+'/app/files/userImageFile.ajx.php', {},
		function(responseData) {
		   if(responseData == "Login") {
		      //loadLogin();
		   }else if(responseData == "failed") {
		      unlockPage();
		   }else {
			  $("#avtarWindow").html(responseData);
		   }
		});
	scroll(0,0);
}

function userFileUpload(tForm, uri){ 
	$('#userfileLoading').show();
	var selection = $("input[@name='userImgs']:checked").val();
	$.ajaxUpload({
            uploadform: tForm,
            url: uri,
            secureuri: false,
            dataType: 'json',
            success: function (message) {
		      var response = filterResponse(message);
			  if(message == "Login") {
				 //loadLogin();
				 return;
			  }
			  if(response.status == "success") {
				  location.reload(); 
			  }
			  else {
				    tForm.reset();
					$('#userfileLoading').hide();
					$('#userImgErr').html(response.error);
					$('#userImgErr').show();
					//$('#uploadErr').fadeOut(5000);
			  }
            },
            error: function (msg, status, e) {
				alert(msg);
				var response = filterResponse(msg);
                 alert(e + ' ' + msg );
                }
     		 });
}


function selectUserUpload() {
	$("input[@name='userImgs']")[3].click();
}
function lockPage(){
	$("select").css({ visibility:"hidden"});
	$("body").append("<div id='pageLock'></div>");
	
	overlaySize();
}
function unlockPage(){
	$("select").css({ visibility:"visible"});;
	$('#pageLock').remove();
	$("#avtarWindow").remove();
}

function overlaySize(){
	if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) {  
		yScroll  = window.innerHeight + window.scrollMaxY;
		xScroll  = window.innerWidth + window.scrollMaxX;
		var deff = document.documentElement;
		var wff  = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
		var hff  = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
		xScroll -= (window.innerWidth - wff);
		yScroll -= (window.innerHeight - hff);
		
	}else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac
		yScroll  = document.body.scrollHeight;
		xScroll  = document.body.scrollWidth;
		
	}else{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
	
			yScroll = document.body.offsetHeight;
		xScroll  = document.body.offsetWidth;
	}
	
	if(screen.height > yScroll) {
		yScroll = screen.height;
	}
	
	$("#pageLock").css({"height": yScroll, "width": xScroll});
}

function filterResponse(responseData){
	var response = responseData;
	try	{
		response = response.replace(/\r/g, "\\r");
		response = response.replace(/\n/g, "\\n");
		response = response.replace(/&quot;/g, '\\"');
		response = response.replace(/&amp;/g, '\\&');
		response = eval("(" + response + ")");
		return response;
	}
	catch(err)
	{
		var response = responseData;
		try	{
			response = eval("(" + response + ")");
			return response;
		}
		catch(err)
		{
			return false;
		}
		return false;
	}
	
}
function loadairinstallwin() {
	if($("#pageLock").css("display") != 'block') {
	   lockInstallPage();
	}
	$("#pageLock").html('');
	$("#installWindow").remove();
	$("body").append("<div id='installWindow'></div>");
	
	$.post(appUrl+'/badge/EmbedDemo.html', {},
		function(responseData) {
		   	  $("#installWindow").html(responseData);
		});
	scroll(0,0);
}

function unlockInstallWin(){
	$("select").css({ visibility:"visible"});;
	//$('#pageLockInstall').remove();
	$('#pageLock').remove();
	$("#installWindow").remove();
}

function lockInstallPage(){
	$("select").css({ visibility:"hidden"});
	$("body").append("<div id='pageLock'></div>");
	overlaySize();
}
function forgotPassword(){
	$('#forgoterrorBoxMsg').html("");	
	$('#method').val("FORGOT");
	$('#loginWin').hide();
	$('#forgotWin').show();
}
function postForgotCancel(){
	$('#method').val("");
	$('#loginWin').show();
	$('#forgotWin').hide();
	
}

function postReset(){
	$('#method').val("FORGOT");
	var email = $('#forgotemail');
	var errorMessage = "";
	if( !isValidEmail(email) ){
		errorMessage = "Please enter valid email.";	
	}
	if( errorMessage !=""){
		$('#forgoterrorBoxMsg').html(errorMessage);	
	}else{
		document.frmLogin.submit();
	}
}
function beta(){
	var winwidth, winheight;
	var NS = false;
	try{
		NS = (navigator.appName=="Netscape")?true:false;
	}catch(e){
		
	}
	if(NS){
		winwidth=720;
		winheight=500;
		
	}else{
		winwidth=670;
		winheight=510;
	}
	winwidth=720;
	winheight=500;
	wposx=(screen.width-660 )/2;
	wposy=(screen.height-510 )/2;;
	file =  appUrl + '/beta.php';
	popupWin = window.open(file, "iplotzbeta", "status=no,resizable=no,toolbar=no,scrollbars=yes,screenX=" + wposx + ",screenY=0,left=" + wposx + ",top=" + wposy + ",width=" + winwidth + ",height=" + winheight);
	popupWin.focus();
}
function showNews(){
			$('#shortText').hide();
			$('#moreIcon').hide();
			$('#newsContent').show();
}
function hideNews(){
	$('#shortText').show();
	$('#moreIcon').show();
	$('#newsContent').hide();
}		
function downloadTranslation(lan){
	var winwidth, winheight;
	winwidth=1200;
	winheight=1000;
	wposx=0;
	wposy=0;
	var file="";
	if( lan=="eng" ){
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfNGM4Z3B2amNq&hl=en";	
	}else if( lan=="ger" ){
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfN2doaDdyOWNj&hl=en";	
	}else if( lan=="spa" ){
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfOGR0NndqMmZr&hl=en";	
	}else if( lan=="fre" ){
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfNWZ3enhwemdn&hl=en";	
	}else if( lan=="ita" ){
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfOWR4NnBmbmZi&hl=en";	
	}else if( lan=="por" ){
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfNnJoaGdxdmhk&hl=en";	
	}else if( lan=="rus" ){
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfM2M3dGpzM2My&hl=en";	
	}else if( lan=="cat" ){
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfMTJmamp2cWJmcQ&hl=en";	
	}else if( lan=="dut" ){
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfMTBzaHhwZDQ0Yw&hl=en";	
	}else if( lan=="kor" ){
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfMTRna3J2c21jaA&hl=en";	
	}else if( lan=="pol" ){
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfMTNoZmNiZmRnaw&hl=en";	
	}else if( lan=="heb" ){
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfMTZnZ3o4ajhjOA&hl=en";	
	}else if( lan=="est" ){
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfMTdkbnRzcW5jNg&hl=en";	
	}else if( lan=="rom" ){
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfMThnc3Q0ZzdyNA&hl=en";	
	}else if( lan=="hun" ){
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfMTVmbmZqcGZmcA&hl=en";	
	}else{
		file ="http://docs.google.com/Doc?docid=0AZW_75lPCwEJZGYzNGZiNGhfNGM4Z3B2amNq&hl=en";	
	}
	
	
	popupWin = window.open(file, "iplotztranslation", "status=no,resizable=yes,toolbar=no,scrollbars=yes,screenX=" + wposx + ",screenY=0,left=" + wposx + ",top=" + wposy + ",width=" + winwidth + ",height=" + winheight);
	popupWin.focus();
}