var RegName = "You must enter a name.";
var RegNameMinLen = "Please enter at least 3 characters in the \"Name\" field.";
var RegNameMaxLen = "Please enter at most 50 characters in the \"Name\" field.";
var RegEmail = "Please enter a value for the Email field.";
var RegEmailTest = "Please enter a valid e-mail address.";
var RegAddressMaxLen = "Please enter at most 150 characters in the address field.";
var RegCity = "You must enter a City Name.";
var RegCityMinLen ="Please enter at least 3 characters in the \"City Name\" field.";
var RegCityMaxLen ="Please enter at most 50 characters in the \"City Name\" field.";
var RegZip = "Please enter a value for the \"ZipCode\" field.";
var BankName = "You must enter the Bank Name.";
var BankCode = "You must enter the Bank Code";
var BankAccount = "You must enter the Bank Account";
var BankSwift = "You must enter the Bank Swift";

var ShopDel = "Do you really want to delete this Shop?";
var PrdDel = "Do you really want to delete this Product?";

var PName = "You must enter a name.";
var PNameMinLen = "Please enter at least 3 characters in the Name field";
var PNameMaxLen = "Please enter less than 50 characters in the Name filed";
var PDescr = "Please enter a description for your product";
var PCateg = "Please select a product category";
var Price = "Please enter a value for the Price field.";
var PriceMinLen = "Please enter at least 1 characters in the Price field.";
var PriceDigit = "Please enter only digit characters in the Price field.";
var DomShip = "Please enter only digit characters in the Domestic Shipping field.";
var IntShip = "Please enter only digit characters in the Interanational Shipping field.";
var Qnt = "Please enter a value for the Quantity field.";
var QntMinLen = "Please enter at most 5 characters in the Quantity field";
var QntDigit = "Please enter only digit characters in the Quantity field.";
var PrdImgDel = "Do you really want to delete this Product Image?";

var ProfileDel = "Do you really want to delete your Profile?\n In this case you will lose all your shops, products and all your stuff in here,\n in other words you will lose your account on KVU.";
var CommDel = "Do you really want to delete this Comment?";
var PrfImgDel = "Do you really want to delete this Profile Image?";

var msgSub = "Please enter a subject first (at least 4 characters)!";
var msgMsg = "Please enter a message first (at least 10 characters)!";
var msgDel = "Are you sure you want to delete this message(s)?";
var msgErr = "Please choose a friend from the dropdown list!";
var frndEnd = "Are you sure you want to terminate the selected friendship(s)?";

var invConn = "Connecting to mail server...";
var invUnChckAll = "uncheck all";
var invChckAll = "check all";
var invTryAn = "To try another e-mail account, please click";
var invClckHr = "here";
var invYrPass = "and password";
var invYrMl = "Your e-mail address";
var invTxt1 = "Here you can import contacts from any of your e-mail account";
var invDwnld2 = "Download contacts";
var invDwnld = "Downloading contacts...";
var invWrngMl = "Wrong email address!";


var onFriendLink = 0;
var onFriendDiv = 0;
var onPostLink = 0;
var onPostDiv = 0;
var mdd_timeout = 100;

var checkedcounter = 0;

var offsetX = 0;
var offsetY = 0;

function createRequestObject() {
	var xmlHttp;
	try { // Firefox, Opera 8.0+, Safari AND IE7 !!!
		xmlHttp=new XMLHttpRequest();
	} catch (e) { // Internet Explorer 5.01, 5.5, 6
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); //IE 6
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); //IE 5.01, 5.5
			} catch (e) {
				//alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return xmlHttp;
}


var http = createRequestObject();

function FormRegShop_Validator(theForm)
{

	if (theForm.shop_name.value == "")
	{
		alert(RegName);
		theForm.shop_name.focus();
		return (false);
	}

	if (theForm.shop_name.value.length < 3)
	{
		alert(RegNameMinLen);
		theForm.shop_name.focus();
		return (false);
	}

	if (theForm.shop_name.value.length > 50)
	{
		alert(RegNameMaxLen);
		theForm.shop_name.focus();
		return (false);
	}


	if (theForm.shop_email.value == "")
	{
		alert(RegEmail);
		theForm.shop_email.focus();
		return (false);
	}

	var EmailValid = false;
	EmailValid=checkMail(theForm.shop_email.value);

	if (!EmailValid)
	{
		alert(RegEmailTest);
		theForm.shop_email.focus();
		return (false);
	}

	if (theForm.shop_address.value.length > 150)
	{
		alert(RegAddressMaxLen);
		theForm.shop_address.focus();
		return (false);
	}

	if (theForm.shop_city_name.value == "")
	{
		alert(RegCity);
		theForm.shop_city_name.focus();
		return (false);
	}
	
	if (theForm.shop_city_name.value.length < 3)
	{
		alert(RegCityMinLen);
		theForm.shop_city_name.focus();
		return (false);
	}

	if (theForm.shop_city_name.value.length > 50)
	{
		alert(RegCityMaxLen);
		theForm.shop_city_name.focus();
		return (false);
	}

	if (theForm.shop_zipcode.value == "")
	{
		alert(RegZip);
		theForm.shop_zipcode.focus();
		return (false);
	}

}

function checkMail(mailAddress) 
{
	var checkRegExpStr = /^\w+((\.|\-|(\.\-))?\w+)*@\w+([\.-]?\w+)*(\.\w{2,5})+$/;
	//if(mailAddress!=initMail && !(checkRegExpStr.test(mailAddress)))
	return checkRegExpStr.test(mailAddress);
}



function BankForm_Validator(theForm)
{
	var alertmsg = '';
	with(theForm) {
		if(!bank_name.value){
			alertmsg += BankName+'\n\n';
			setRedBorder(bank_name);
		}
		if(!bank_code.value){
			alertmsg += BankCode+'\n\n';
			setRedBorder(bank_code);
		}
		if(!bank_account.value){
			alertmsg += BankAccount+'\n\n';
			setRedBorder(bank_account);
		}
	}
	if(alertmsg) {
		alert(alertmsg);
		return false;
	}
	return true;
}

function confirmShopDel()
{
	var d=confirm(ShopDel);
	if (d)
		return true ;
	else
		return false ;
}

__=function positioningNamespace() {
	function gP(e){
		var left=0;
		var top=0;
		while (e.offsetParent){
			left+=e.offsetLeft-e.scrollLeft;
			top+=e.offsetTop;
			e=e.offsetParent;
		}
		left+=e.offsetLeft-e.scrollLeft;
		top+=e.offsetTop;
		return {x:left, y:top};
	}
     window.getPos = gP;
}();


function showPopUpPrd(id)
{
	id=id.toString();
	var prod = 'prd_'+id;
	var referralObj = document.getElementById(prod);
	var popUpPrd=document.getElementById('popUpPrd_'+id);
	popUpPrd.style.visibility='visible';
	var cords = getPos(referralObj);
	var leftStr =  (cords.x+5) + "px";
	var topStr = (cords.y-50) + "px";
	popUpPrd.style.left=leftStr;
	popUpPrd.style.top=topStr;
}

function hidePopUpPrd(id)
{
	id=String(id);
	var popUpPrd=document.getElementById('popUpPrd_'+id);	
	popUpPrd.style.visibility='hidden';
}

function confirmPrdDel()
{
var a=confirm(PrdDel);
if (a)
	return true ;
else
	return false ;
}

function confirmPrdImgDel()
{
var c=confirm(PrdImgDel);
if (c)
	return true ;
else
	return false ;
}

function activeInactive(checkbox)
{
	var subactinact=document.getElementById("jsubactinact");
	
	if(checkbox.checked==true)
		checkedcounter++;
	if(checkbox.checked==false)
		checkedcounter--;
	
	if(checkedcounter==0)
		subactinact.disabled=true;
	if(checkedcounter==1)
		subactinact.disabled=false;
}

function Form1_Validator(theForm)
{
	var alertmsg = '';
	with(theForm) {
		if(!prdname.value){
			alertmsg += PName+'\n\n';
			setRedBorder(prdname);
		}
		if(!prddescr.value){
			alertmsg += PDescr+'\n\n';
			setRedBorder(prddescr);
		}
		if(prdcat.value==0){
			alertmsg += PCateg+'\n\n';
			setRedBorder(prdcat);
		}
		if(!prdprice.value.match(/^[0-9]+([\.,][0-9]+)?$/)) {
			alertmsg += Price+'\n\n';
			setRedBorder(prdprice);
		}
		if(!prddomshp.value.match(/^[0-9]+([\.,][0-9]+)?$/)) {
			alertmsg += DomShip+'\n\n';
			setRedBorder(prddomshp);
		}
		if(!prd_ship_int.value.match(/^[0-9]+([\.,][0-9]+)?$/)) {
			alertmsg += IntShip+'\n\n';
			setRedBorder(prd_ship_int);
		}
		if(!prdqnt.value.match(/^[0-9]+$/)) {
			alertmsg += Qnt+'\n\n';
			setRedBorder(prdqnt);
		}
	}
	if(alertmsg) {
		alert(alertmsg);
		return false;
	}
	return true;
}

function ChldSelect(lngslt)
{	
	var selObj = document.getElementById("prdcat");
	var selObj1 = document.getElementById("prdcat1");
	var parentId=selObj.options[selObj.selectedIndex].value;
	
	if(parentId=="")
	{ 
		var n = selObj1.length;
			for(var i=0; i<n; i++)
    				selObj1.remove(0);
		return;
	}
	
	http = new createRequestObject();

	if(http.readyState!=0)
		http.abort();
	http.onreadystatechange=function()
	{
		if(http.readyState == 4) 
		{
			var n = selObj1.length;
			for(var i=0; i<n; i++)
    				selObj1.remove(0);
			
			var response ="";
			response=http.responseText;
			
			var respons=response.split(":SEPARATOR2:");
			
			for(i=0; i<respons.length-1; i++)
			{
				var rsp=respons[i].split(":SEPARATOR1:");
				  var y=document.createElement('option');
				y.value=rsp[0];
				y.text=rsp[1];
				try
				{
					selObj1.add(y,null); // standards compliant
    				}
  				catch(ex)
				{
    					selObj1.add(y); // IE only
    				}
			}
		}
	}
	http.open('get', '/acategories.php?lngslt='+lngslt+'&parent='+parentId);
	http.send(null);
}

function mChldSelect()
{	
	var selObj = document.getElementById("mprdcat");
	var selObj1 = document.getElementById("mprdcat1");
	var parentId=selObj.options[selObj.selectedIndex].value;

	if(parentId==0)
	{ 
		var n = selObj1.length;
			for(var i=0; i<n; i++)
    				selObj1.remove(0);

		return;
	}
	
	http = new createRequestObject();
	
	if(http.readyState!=0)
		http.abort();
	http.onreadystatechange=function()
	{
		if(http.readyState == 4) 
		{
			var n = selObj1.length;
			for(var i=0; i<n; i++)
    				selObj1.remove(0);
			
			var response ="";
			response=http.responseText;
			
			var respons=response.split(":SEPARATOR2:");

			for(i=0; i<respons.length-1; i++)
			{
				var rsp=respons[i].split(":SEPARATOR1:");
				  var y=document.createElement('option');
				y.value=rsp[0];
				 y.text=rsp[1];
				try
				{
					selObj1.add(y,null); // standards compliant
    				}
  				catch(ex)
				{
    					selObj1.add(y); // IE only
    				}
			}
		}
	}	
	
	http.open('get', '/acategories.php?parent='+parentId);
	http.send(null);
}

function setColor(ttd)
{
	for(ttdChildIdx=0; ttdChildIdx<ttd.childNodes.length; ttdChildIdx++)
			if(typeof(ttd.childNodes[ttdChildIdx].checked)!='undefined')
				break;
	var checkbox = ttd.childNodes[ttdChildIdx];
	if(!checkbox.checked) {
		checkbox.checked = true;
		ttd.style.border = "2px dashed #000000";
		if(ttd.bgColor=="#000000" || ttd.bgColor=="#0000ff" || ttd.bgColor=="#663300")
			ttd.style.border = "2px dashed #999999";
	} else {
		checkbox.checked = false;
		ttd.style.border = "2px solid #ffffff";
	}
}

function show_picture(text_nr, lngslt)
{
	var arrow1=document.getElementById("arrow1");
	var arrow2=document.getElementById("arrow2");
	var arrow3=document.getElementById("arrow3");

	var div=document.getElementById("tags_proposition");
	
	var t_tech=document.getElementById("technique");
	var t_mat=document.getElementById("material");
	var t_fft=document.getElementById("fftags");
	
	var selObj1 = document.getElementById("prdcat1");
	
	
	if(selObj1.selectedIndex == -1)
		return;

		
	var childId=selObj1.options[selObj1.selectedIndex].value;

	if(text_nr==1)
	{
		http = new createRequestObject();
		div.style.display = "block";
		
		arrow1.style.visibility = "visible";
		arrow2.style.visibility = "hidden";
		arrow3.style.visibility = "hidden";

		t_tech.style.backgroundColor="#ffffdd";
		t_mat.style.backgroundColor="#ffffff";
		t_fft.style.backgroundColor="#ffffff";
		if(http.readyState!=0 && http.readyState!=4) {
			http.abort();
		}
		http.onreadystatechange=function()
		{
			if(http.readyState == 4) 
			{		
				var response ="";
				response=http.responseText;
				div.innerHTML=response;
			}
		}

		http.open('get', '/atechnique/lngslt/'+lngslt+'/cat/'+childId);
		http.send(null);
	}
	else if(text_nr==2)
	{	
		http = new createRequestObject();
		
		div.style.display = "block";
		
		arrow1.style.visibility = "hidden";
		arrow2.style.visibility = "visible";
		arrow3.style.visibility = "hidden";

		t_tech.style.backgroundColor="#ffffff";
		t_mat.style.backgroundColor="#ffffdd";
		t_fft.style.backgroundColor="#ffffff";
		if(http.readyState!=0 && http.readyState!=4)
			http.abort();
		http.onreadystatechange=function()
		{
			if(http.readyState == 4) 
			{		
				var response ="";
				response=http.responseText;
				div.innerHTML=response;
			}
		}
		http.open('get', '/amaterial/lngslt/'+lngslt+'/cat/'+childId);
		http.send(null);

	}
	else if(text_nr==3)
	{
		http = new createRequestObject();
		
		div.style.display = "block";
	
		arrow1.style.visibility = "hidden";
		arrow2.style.visibility = "hidden";
		arrow3.style.visibility = "visible";

		t_tech.style.backgroundColor="#ffffff";
		t_mat.style.backgroundColor="#ffffff";
		t_fft.style.backgroundColor="#ffffdd";
		if(http.readyState!=0 && http.readyState!=4)
			http.abort();
		http.onreadystatechange=function()
		{
			if(http.readyState == 4) 
			{		
				var response ="";
				response=http.responseText;
				div.innerHTML=response;
			}
		}
		http.open('get', '/afreeformtags/lngslt/'+lngslt+'/cat/'+childId);
		http.send(null);

	}	
}

function show_mpicture(text_nr, lngslt)
{
	var arrow1=document.getElementById("arrowm1");
	var arrow2=document.getElementById("arrowm2");
	var arrow3=document.getElementById("arrowm3");

	var div=document.getElementById("tags_mproposition");
	
	var t_tech=document.getElementById("mtechnique");
	var t_mat=document.getElementById("mmaterial");
	var t_fft=document.getElementById("mfftags");
	
	var selObj1 = document.getElementById("mprdcat1");	
	
	if(selObj1.selectedIndex == -1)
		return;
		
	var childId=selObj1.options[selObj1.selectedIndex].value;	

	if(text_nr==1)
	{
		http = new createRequestObject();
		div.style.display = "block";
		
		arrow1.style.visibility = "visible";
		arrow2.style.visibility = "hidden";
		arrow3.style.visibility = "hidden";

		t_tech.style.backgroundColor="#ffffdd";
		t_mat.style.backgroundColor="#ffffff";
		t_fft.style.backgroundColor="#ffffff";
		if(http.readyState!=0 && http.readyState!=4)
			http.abort();
		
		http.onreadystatechange=function()
		{
			if(http.readyState == 4) 
			{		
				var response ="";
				response=http.responseText;
				div.innerHTML=response;
			}
		}
		http.open('get', '/amtechnique/lngslt/'+lngslt+'/cat/'+childId);
		http.send(null);

	}
	else if(text_nr==2)
	{	
		http = new createRequestObject();
		div.style.display = "block";
		
		arrow1.style.visibility = "hidden";
		arrow2.style.visibility = "visible";
		arrow3.style.visibility = "hidden";

		t_tech.style.backgroundColor="#ffffff";
		t_mat.style.backgroundColor="#ffffdd";
		t_fft.style.backgroundColor="#ffffff";
		if(http.readyState!=0 && http.readyState!=4)
			http.abort();
		
		http.onreadystatechange=function()
		{
			if(http.readyState == 4) 
			{
		
				var response ="";
				response=http.responseText;
				div.innerHTML=response;
			}
		}
		http.open('get', '/ammaterial/lngslt/'+lngslt+'/cat/'+childId);
		http.send(null);
	}
	else if(text_nr==3)
	{
		http = new createRequestObject();
		div.style.display = "block";
	
		arrow1.style.visibility = "hidden";
		arrow2.style.visibility = "hidden";
		arrow3.style.visibility = "visible";

		t_tech.style.backgroundColor="#ffffff";
		t_mat.style.backgroundColor="#ffffff";
		t_fft.style.backgroundColor="#ffffdd";
		if(http.readyState!=0 && http.readyState!=4)
			http.abort();
		
		http.onreadystatechange=function()
		{
			if(http.readyState == 4) 
			{		
				var response ="";
				response=http.responseText;
				div.innerHTML=response;
			}
		}
		http.open('get', '/amfreeformtags/lngslt/'+lngslt+'/cat/'+childId);
		http.send(null);
	}	
}

function int_shipping()
{
	var chck=document.getElementById("w_ship_int");
	var txt=document.getElementById("prd_ship_int");

	if(chck.checked==true)
		txt.disabled=false;
	else if(chck.checked==false)
		txt.disabled=true;
}

function sellLinkName(lngslt)
{
	var url = document.URL;
	var matchFound = url.match('index');

	if('index' == matchFound)
	{
		var loggedIn=document.getElementById('ysn_logged_in');
		if(loggedIn.value==1)
		{
			document.location.href='/sellw/lngslt/'+lngslt+'/action/shops';
			return false;		
		}
		else
			return true;
	}		
}

function toggle_tag(txtId, tag_name)
{
	var myStr = document.getElementById(txtId).value;
	if(myStr.indexOf(tag_name) != -1)
		return false;
	else
	{
		var taObj=document.getElementById(txtId);
		taObj.value+=tag_name+",";
	}
}


// --- FormRegShop_Validator ---
function regshopvar_init(regname, regnameminlen, regnamemaxlen,  regemail, regemailtest, regaddressmaxlen,  regcity, regcityminlen, regcitymaxlen, regzip)
{
	if(regname) RegName = regname;
	if(regnameminlen) RegNameMinLen = regnameminlen;
	if(regnamemaxlen) RegNameMaxLen = regnamemaxlen;
	if(regemail) RegEmail = regemail;
	if(regemailtest) RegEmailTest = regemailtest;
	if(regaddressmaxlen) RegAddressMaxLen = regaddressmaxlen;
	if(regcity) RegCity = regcity;
	if(regcityminlen) RegCityMinLen = regcityminlen;
	if(regcitymaxlen) RegCityMaxLen = regcitymaxlen;
	if(regzip) RegZip = regzip;	
}

// --- BankForm_Validator ---
function regbank_init(bankname, bankcode, bankaccount)
{
	if(bankname) BankName = bankname;
	if(bankcode) BankCode = bankcode;
	if(bankaccount) BankAccounr = bankaccount;
//	if(bankswift) BankSwift=bankswift;
}

// --- confirmShopDel ---
function shopdel_init(shopdel)
{
	if(shopdel) ShopDel = shopdel;
}

// --- Form1_Validator  ---
function var_init(prdcategdel, prddel, prdimgdel, pname, pnameminlen, pnamemaxlen,  pdescr, pcateg,  price, priceminlen, pricedigit, domship, intship, qnt, qntminlen, qntdigit)
{
	if(prdcategdel) PrdCategDel = prdcategdel;
	if(prddel) PrdDel = prddel;
	if(prdimgdel) PrdImgDel = prdimgdel;
	if(pname) PName = pname;
	if(pnameminlen) PNameMinLen = pnameminlen;
	if(pnamemaxlen) PNameMaxLen = pnamemaxlen;
	if(pdescr) PDescr = pdescr;
	if(pcateg) PCateg = pcateg;
	if(price) Price = price;
	if(priceminlen) PriceMinLen = priceminlen;
	if(pricedigit) PriceDigit = pricedigit;
	if(domship) DomShip = domship;
	if(intship) IntShip = intship;
	if(qnt) Qnt = qnt;
	if(qntminlen) QntMinLen = qntminlen;
	if(qntdigit) QntDigit = qntdigit;	
}


function msgFrndInv_init(msgSub2, msgMsg2, msgDel2, msgErr2, frndEnd2, invConn2, invUnChckAll2, invChckAll2, invTryAn2, invClckHr2, invYrPass2, invYrMl2, invTxt12, invDwnld22, invDwnld2, invWrngMl2) {
	if (msgSub2) msgSub = msgSub2;
	if (msgMsg2) msgMsg = msgMsg2;
	if (msgDel2) msgDel = msgDel2;
	if (msgErr2) msgErr = msgErr2;
	if (frndEnd2) frndEnd = frndEnd2;
	if (invConn2) invConn = invConn2;
	if (invUnChckAll2) invUnChckAll = invUnChckAll2;
	if (invChckAll2) invChckAll = invChckAll2;
	if (invTryAn2) invTryAn = invTryAn2;
	if (invClckHr2) invClckHr = invClckHr2;
	if (invYrPass2) invYrPass = invYrPass2;
	if (invYrMl2) invYrMl = invYrMl2;
	if (invTxt12) invTxt1 = invTxt12;
	if (invDwnld22) invDwnld2 = invDwnld22;
	if (invDwnld2) invDwnld = invDwnld2;
	if (invWrngMl2) invWrngMl = invWrngMl2;
}

//opt

function Form4_Validator(theForm)
{
	if (theForm.curent_password.value.length < 5)
	{
		alert(RegPassMinLen);
		theForm.curent_password.focus();
		return (false);
	}

	if (theForm.curent_password.value.length > 50)
	{
		alert(RegPassMaxLen);
		theForm.curent_password.focus();
		return (false);
	}

	var checkOK1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	var checkStr1 = theForm.curent_password.value;
	var allValid1 = true;
	for (i = 0;  i < checkStr1.length;  i++)
	{
		ch = checkStr1.charAt(i);
		for (j = 0;  j < checkOK1.length;  j++)
			if (ch == checkOK1.charAt(j))
				break;
		if (j == checkOK1.length)
		{
			allValid1 = false;
			break;
		}
	}
	if (!allValid1)
	{
		alert(RegPassLNChar);
		theForm.curent_password.focus();
		return (false);
	}

	if (theForm.uname.value == "")
	{
		alert(RegName);
		theForm.uname.focus();
		return (false);
	}

	if (theForm.uname.value.length < 3)
	{
		alert(RegNameMinLen);
		theForm.uname.focus();
		return (false);
	}

	if (theForm.uname.value.length > 50)
	{
		alert(RegNameMaxLen);
		theForm.uname.focus();
		return (false);
	}

	if (theForm.usurename.value == "")
	{
		alert(RegSurname);
		theForm.uname.focus();
		return (false);
	}

	if (theForm.usurename.value.length < 3)
	{
		alert(RegSurnameMinLen);
		theForm.usurename.focus();
		return (false);
	}

	if (theForm.usurename.value.length > 50)
	{
		alert(RegSurnameMaxLen);
		theForm.usurename.focus();
		return (false);
	}

	if (theForm.city_name.value == "")
	{
		alert(RegCity);
		theForm.city_name.focus();
		return (false);
	}

	if (theForm.city_name.value.length < 3)
	{
		alert(RegCityMinLen);
		theForm.city_name.focus();
		return (false);
	}

	if (theForm.city_name.value.length > 50)
	{
		alert(RegCityMaxLen);
		theForm.city_name.focus();
		return (false);
	}

	if (theForm.zip_code.value == "")
	{
		alert(RegZip);
		theForm.zip_code.focus();
		return (false);
	}


	if (theForm.address.value.length > 150)
	{
		alert(RegAddressMaxLen);
		theForm.address.focus();
		return (false);
	}
}

function setRedBorder(inp) {
	inp.style.border = '2px solid #f00';
	inp.focus();
}

function FormShopData_Validator(theForm)
{
	var alertmsg = '';
	with(theForm) {
		if(!shop_name.value){
			alertmsg += RegName+'\n\n';
			setRedBorder(shop_name);
		}					
		if (!(EmailValid=checkMail(shop_email.value))) {
			alertmsg += RegEmailTest+'\n\n';
			setRedBorder(shop_email);
		}
		if(!shop_address.value){
			alertmsg += 'The Address Field is empty'+'\n\n';
			setRedBorder(shop_address);
		}					
		if(!shop_city_name.value){
			alertmsg += RegCity+'\n\n';
			setRedBorder(shop_city_name);
		}
		if(!shop_zipcode.value){
			alertmsg += RegZip+'\n\n';
			setRedBorder(shop_zipcode);
		}
		if(!bank_name.value){
			alertmsg += BankName+'\n\n';
			setRedBorder(bank_name);
		}
		if(!bank_code.value){
			alertmsg += BankCode+'\n\n';
			setRedBorder(bank_code);
		}
		if(!bank_account.value){
			alertmsg += BankAccount+'\n\n';
			setRedBorder(bank_account);
		}
	}
	if(alertmsg) {
		alert(alertmsg);
		return false;
	}
	return true;


/*	if (theForm.bank_swift.value == "")
	{
		alert(BankSwift);
		theForm.bank_swift.focus();
		return (false);
	}
*/	

}

function shopdatavar_init(regname, regnameminlen, regnamemaxlen,  regemail, regemailtest, regaddressmaxlen,  regcity, regcityminlen, regcitymaxlen, regzip, bankname, bankcode, bankaccount)
{
	if(regname) RegName = regname;
	if(regnameminlen) RegNameMinLen = regnameminlen;
	if(regnamemaxlen) RegNameMaxLen = regnamemaxlen;
	if(regemail) RegEmail = regemail;
	if(regemailtest) RegEmailTest = regemailtest;
	if(regaddressmaxlen) RegAddressMaxLen = regaddressmaxlen;
	if(regcity) RegCity = regcity;
	if(regcityminlen) RegCityMinLen = regcityminlen;
	if(regcitymaxlen) RegCityMaxLen = regcitymaxlen;
	if(regzip) RegZip = regzip;
	if(bankname) BankName = bankname;
	if(bankcode) BankCode = bankcode;
	if(bankaccount) BankAccounr = bankaccount;
//	if(bankswift) BankSwift=bankswift;
}

function FormShopData1_Validator(theForm)
{
	var alertmsg = '';
	var http = new createRequestObject();
	var numb=Math.random(10)+1;
	
	with(theForm) {
		if(!(/^[a-zA-Z0-9 ßäöüÄÖÜ\.\-]{2,}$/).test(shop_name.value)){
			alertmsg += RegName+'\n\n';
			setRedBorder(shop_name);
		}					
		if (!(EmailValid=checkMail(shop_email.value))) {
			alertmsg += RegEmailTest+'\n\n';
			setRedBorder(shop_email);
		}
		if(!shop_address.value){
			alertmsg += 'The Address Field is empty'+'\n\n';
			setRedBorder(shop_address);
		}					
		if(!(/^[a-zA-Z ßäöüÄÖÜ\.\-]{2,}$/).test(shop_city_name.value)){
			alertmsg += RegCity+'\n\n';
			setRedBorder(shop_city_name);
		}
		if(!shop_zipcode.value){
			alertmsg += RegZip+'\n\n';
			setRedBorder(shop_zipcode);
		}
	}
	
	http.onreadystatechange = function () 
	{
		if (http.readyState==4 && http.status==200) 
		{
			var JSONobj=eval('(' + http.responseText + ')');
			
			if(JSONobj.status==1)
			{
				var bnk_error=0;
				if(!theForm.bank_accowner.value)
				{
					bnk_error++;
					setRedBorder(theForm.bank_accowner);
					theForm.bank_accowner.value=JSONobj.bankaccowner;
				}
			
				if(!theForm.bank_name.value)
				{
					bnk_error++;
					setRedBorder(theForm.bank_name);
					theForm.bank_name.value=JSONobj.bankname;
				}

				if(!theForm.bank_code.value)
				{
					bnk_error++;
					setRedBorder(theForm.bank_code);
					theForm.bank_code.value=JSONobj.bankcode;
				}

				if(!theForm.bank_account.value)
				{
					bnk_error++;
					setRedBorder(theForm.bank_account);
					theForm.bank_account.value=JSONobj.bankaccount;
				}
			
				if(bnk_error!=0)
				{
					alertmsg +='The fields coresponding to the Account owner, BankName, BankCode, BankAccount can\'t be unfilled, once you have allready filled them.'+'\n\n';	
					
				}	
			}
			else if(JSONobj.status==0)
			{
				var bnk_error=0;
				if(theForm.bank_accowner.value)
					bnk_error++;
			
				if(theForm.bank_name.value)
					bnk_error++;

				if(theForm.bank_code.value)
					bnk_error++;

				if(theForm.bank_account.value)
					bnk_error++;
					
				if(theForm.bank_accowner.value && theForm.bank_name.value && theForm.bank_code.value && theForm.bank_account.value)
					bnk_error=0;
					
				if(bnk_error!=0)
				{
					alertmsg +='If you decide to fill in the fields coreponding to the bankdata you should fill in all the fields coresponding to the Account owner, BankName, BankCode, BankAccount'+'\n\n';
					alertmsg +='Be carefull and fill in those fields with true data. This is important for a good process of selling yours products'+'\n\n';
					setRedBorder(theForm.bank_accowner);
					setRedBorder(theForm.bank_name);
					setRedBorder(theForm.bank_code);
					setRedBorder(theForm.bank_account);
				}	
			}
		}	
	}
	http.open('GET', '/checkbankdata.php?sid='+numb);
	http.send(null);
	
	if(alertmsg) {
		alert(alertmsg);
		return false;
	}
	return true;
}

function FormShopData2_Validator(theForm)
{
	var alertmsg = '';
	var http = new createRequestObject();
	var numb=Math.random(10)+1;
	
	with(theForm) {		
		if(!(/^[a-zA-Z0-9 ßäöüÄÖÜ\.\-]{2,}$/).test(shop_name.value)){
			alertmsg += RegName+'\n\n';
			setRedBorder(shop_name);
		}					
		if (!(EmailValid=checkMail(shop_email.value))) {
			alertmsg += RegEmailTest+'\n\n';
			setRedBorder(shop_email);
		}
		if(!shop_address.value){
			alertmsg += 'The Address Field is empty'+'\n\n';
			setRedBorder(shop_address);
		}					
		if(!(/^[a-zA-Z ßäöüÄÖÜ\.\-]{2,}$/).test(shop_city_name.value)){
			alertmsg += RegCity+'\n\n';
			setRedBorder(shop_city_name);
		}
		if(!shop_zipcode.value){
			alertmsg += RegZip+'\n\n';
			setRedBorder(shop_zipcode);
		}
		
		var bnk_error=0;
		if(bank_accowner.value)
			bnk_error++;
			
		if(bank_name.value)
			bnk_error++;
			
		if(bank_code.value)
			bnk_error++;

		if(bank_account.value)
			bnk_error++;
					
		if(bank_accowner.value &&  bank_name.value && bank_code.value && bank_account.value)
			bnk_error=0;
					
		if(bnk_error!=0)
		{
			alertmsg +='If you decide to fill in the fields coreponding to the bankdata you should fill in all the fields coresponding to the Account owner, BankName, BankCode, BankAccount'+'\n\n';
			alertmsg +='Be carefull and fill in those fields with true data. This is important for a good process of selling yours products'+'\n\n';
			setRedBorder(bank_accowner);
			setRedBorder(bank_name);
			setRedBorder(bank_code);
			setRedBorder(bank_account);
		}
	}

	if(alertmsg) {
		alert(alertmsg);
		return false;
	}
	return true;
}


function shopdatavar1_init(regname, regnameminlen, regnamemaxlen,  regemail, regemailtest, regaddressmaxlen,  regcity, regcityminlen, regcitymaxlen, regzip)
{
	if(regname) RegName = regname;
	if(regnameminlen) RegNameMinLen = regnameminlen;
	if(regnamemaxlen) RegNameMaxLen = regnamemaxlen;
	if(regemail) RegEmail = regemail;
	if(regemailtest) RegEmailTest = regemailtest;
	if(regaddressmaxlen) RegAddressMaxLen = regaddressmaxlen;
	if(regcity) RegCity = regcity;
	if(regcityminlen) RegCityMinLen = regcityminlen;
	if(regcitymaxlen) RegCityMaxLen = regcitymaxlen;
	if(regzip) RegZip = regzip;
}

function chgaddrvar_init(regpassminlen, regpassmaxlen, regpasslnchar, regemailtest, regname, regnameminlen, regnamemaxlen,  regsurname, regsurnameminlen, regsurnamemaxlen, regcity, regcityminlen, regcitymaxlen,  regzip, regaddressmaxlen)
{
	if(regpassminlen) RegPassMinLen = regpassminlen;
	if(regpassmaxlen) RegPassMaxLen = regpassmaxlen;
	if(regpasslnchar) RegPassLNChar = regpasslnchar;
	if(regemailtest) RegEmailTest = regemailtest;
	if(regname) RegName = regname;
	if(regnameminlen) RegNameMinLen = regnameminlen;
	if(regnamemaxlen) RegNameMaxLen = regnamemaxlen;
//	if(regnamelchar) RegNameLChar = regnamelchar;
	if(regsurname) RegSurname = regsurname;
	if(regsurnameminlen) RegSurnameMinLen = regsurnameminlen;
	if(regsurnamemaxlen) RegSurnameMaxLen = regsurnamemaxlen;
//	if(regsurnamelchar) RegSurnameLChar = regsurnamelchar;
	if(regcity) RegCity = regcity;
	if(regcityminlen) RegCityMinLen = regcityminlen;
	if(regcitymaxlen) RegCityMaxLen = regcitymaxlen;
//	if(regcitylchar) RegCityLChar = regcitylchar;
	if(regzip) RegZip = regzip;
	if(regaddressmaxlen) RegAddressMaxLen = regaddressmaxlen;
}

function confirmProfileDel()
{
var b=confirm(ProfileDel);
if (b)
	return true ;
else
	return false ;
}

function profiledel_init(profiledel)
{
	if(profiledel) ProfileDel = profiledel;
}

function confirmCommDel()
{
var e=confirm(CommDel);
if (e)
	return true ;
else
	return false ;
}

//optp

function confirmPrfImgDel()
{
var a=confirm(PrfImgDel);
if (a)
	return true ;
else
	return false ;
}

function prf_init(prfimgdel)
{
	if(prfimgdel) PrfImgDel = prfimgdel;
}

function FormPrdMsg_Validator(theForm)
{
	if (theForm.msgsubj.value == "")
	{
		alert(MsgPrdSubj);
		theForm.msgsubj.focus();
		return (false);
	}

	if (theForm.msgtext.value == "")
	{
		alert(MsgPrdText);
		theForm.msgtext.focus();
		return (false);
	}
}

function msgprd_init(msgprdsubj, msgprdtext)
{
	if(msgprdsubj) MsgPrdSubj = msgprdsubj;
	if(msgprdtext) MsgPrdText = msgprdtext;
}

function window_width_inx()
{
	var width=screen.availWidth;
	if(width<1000)
		width=1000;
	$('#largeline_top_inx').width(width);
	$('#largeline_middle_inx').width(width);
//	$('#largeline_middle_inx').width(width);
	$('#largeline_bottom_inx').width(width);	
	$('#top_inx').width(width);
	$('#bottom_links').width(width);
	
	if(!$.browser.msie)
		$('#body_inx').width(width);
}


function showPicturesDiv()
{
	var picturesDiv=document.getElementById('picturesDiv');
	picturesDiv.style.display='block';
}

function loadScript(sScriptSrc, oCallback) 
{
	var oHead = document.getElementsByTagName('head')[0];
	var oScript = document.createElement('script');
	oScript.type = 'text/javascript';
	oScript.src = sScriptSrc;
	// most browsers
	oScript.onload = oCallback;
	// IE 6 & 7
	oScript.onreadystatechange = function() 
	{
		if (this.readyState == 'complete') 
		{
			oCallback();
		}	
	}
	oHead.appendChild(oScript);
 }
 
 function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	} else if (obj.x) curleft += obj.x;
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else if (obj.y) curtop += obj.y;
	return curtop;
}
 
 function open_infoUpPic(obj) {
	var dv=document.createElement("div");
	var infoText=document.getElementById("infoUpPic");
	dv.id="infoUpPic_details";
	dv.className="remdiv";
	dv.innerHTML=infoText.innerHTML;
	dv.style.position="absolute";
	dv.style.paddingLeft="2px";
	dv.style.paddingRight="2px";
	dv.style.paddingTop="2px";
	dv.style.paddingBottom="2px";
	dv.style.left=parseInt(findPosX(obj)+20)+"px";
	dv.style.top=parseInt(findPosY(obj)-250)+"px";
	dv.style.borderStyle="solid";
	dv.style.borderWidth="1px";
	dv.style.borderColor="#78C4F5";
	dv.style.width="200px";
	dv.style.backgroundColor="#FFCA1C";
	document.body.appendChild(dv);
}

function real_upPIc_collapse() {
	document.body.removeChild(document.getElementById('infoUpPic_details'));
}
function collapse_upPic() {
	setTimeout("real_upPIc_collapse()",0);
}

function trBuyerGift(divid, id)
{	
	var trBuyer=document.getElementById(id);
	if(divid.style.display=='none')
		 trBuyer.style.display=divid.style.display;
	else if(divid.style.display=='block')
		 trBuyer.style.display=divid.style.display;		
}

function buyerToggle(so) {
	var cr = so.parentNode.parentNode;
	var row = (cr.nextSibling.nodeType==1) ? cr.nextSibling : cr.nextSibling.nextSibling;
	$(row).children('td').children('div').slideToggle(500, function() {
		$(so).children('img').get(0).alt = (this.style.display=='none') ? 'plus' : 'minus';
		$(so).children('img').get(0).src = (this.style.display=='none') ? '/images/plus.gif' : '/images/minus.gif';
	});
}


function giftToggle(so){
	var cr = so.parentNode.parentNode;
	var row = (cr.nextSibling==1) ? cr.nextSibling : cr.nextSibling.nextSibling;
	row = (row.nextSibling==1) ? row.nextSibling : row.nextSibling.nextSibling;
	$(row).children('td').children('div').slideToggle(500, function() {
		$(so).children('img').get(0).alt = (this.style.display=='none') ? 'plus' : 'minus';
		$(so).children('img').get(0).src = (this.style.display=='none') ? '/images/plus.gif' : '/images/minus.gif';
	});
}

function preventEventToPropagate(ev)
{
	if(document.all)
	{
		ev.returnValue=false;
		ev.cancelBubble = true;
	} else {
		ev.preventDefault();
		ev.stopPropagation();
	}
}

var http = createRequestObject();

function createRequestObject() 
{
	var ro; 
	if(window.ActiveXObject){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
	ro = new XMLHttpRequest();
	}
	return ro;
}

function makeRequest_prdmsg(url, lngslt) 
{
	var textBlue=document.getElementById('redirectmsgBlueNote');
	var contentDiv=document.getElementById('redirectmsgPopupTextContainer');
	var userName=document.getElementById('username');
	var userPass=document.getElementById('password');
//	var loginMenu=document.getElementById('login_menu');
	var msgText = (document.getElementById('msgPopupTextContainer'));

	
	
	http = new createRequestObject();

        http.onreadystatechange = function (  ) 
	{
		if (http.readyState == 4) 
		{
			 textBlue.innerHTML=http.responseText;
			 contentDiv.style.display='none';
			 userName.value='';
			 userPass.value='';

			if(http.responseText.indexOf("<input id='ysn_logged_in' type='hidden' value='1' />")!=-1)
			{
				msgText.style.display='block';
//				loginMenu.style.visibility='hidden';
			}	
		}
        }
     http.open('GET', url, true);
     http.send(null);
}

function showmsgMaxAlert(lngslt, id, msg)
{
	id=id.toString();
	var prdmsg= "prdmsg_"+id;
	var referralObj = document.getElementById(prdmsg);
	var loggedIn = (document.getElementById('ysn_logged_in'));
	
	var alertMsgTable = (document.getElementById('redirectmsgDiv'));
	var alertSaveTable = (document.getElementById('redirectsaveDiv'));
	var alertTable = (document.getElementById('redirectDiv'));
	var blueText = (document.getElementById('redirectmsgBlueNote'));
	var contentText = (document.getElementById('redirectmsgPopupTextContainer'));
	var questionProduct=document.getElementById('question_product');

	actual_msg_product=id;	

	if(loggedIn && loggedIn.value==1)
	{
		makeRequest_prdmsg("/login_and_msg_product.php?lngslt="+lngslt+"&product="+actual_msg_product);
		contentText.style.display=='none';
		questionProduct.value='';
	} 
	else
	{
		if(blueText.innerHTML!=msg)
			blueText.innerHTML=msg;
		
		if(contentText.style.display=='none')
			contentText.style.display='block';
	}
	
	
	document.body.onclick=hideMsgMaxAlert;
	if(alertTable.style.visibility == 'visible')
		alertTable.style.visibility = 'hidden';
	if(alertSaveTable.style.visibility == 'visible')
		alertSaveTable.style.visibility = 'hidden';

	var cords = getPos(referralObj);
	var leftStr =  (cords.x-430) + "px";
	var topStr = (cords.y-350) + "px";

	alertMsgTable.style.left=leftStr;
	alertMsgTable.style.top=topStr;
	
	if(!alertMsgTable)
		return false;
	alertMsgTable.style.visibility = 'visible';
	return;
}

function showMaxAlert(id, popupmailtext)
{
	id=id.toString();
	var prdmail = "prdmail_"+id;
	var referralObj = document.getElementById(prdmail);
	var alertMsgTable = (document.getElementById('redirectmsgDiv'));
	var alertTable = (document.getElementById('redirectDiv'));
	var blueText = (document.getElementById('redirectBlueNote'));	
	var contentText = (document.getElementById('redirectPopupTextContainer'));
	
	var alertSaveTable = (document.getElementById('redirectsaveDiv'));
	
	if(blueText.innerHTML!=popupmailtext)
		blueText.innerHTML=popupmailtext;
	else
		blueText.innerHTML=popupmailtext;	
	
	if(contentText.style.display=='none')
		contentText.style.display='block';

	document.body.onclick=hideMaxAlert;
	if(alertSaveTable.style.visibility == 'visible')
		alertSaveTable.style.visibility = 'hidden';
	if(alertMsgTable.style.visibility == 'visible')
		alertMsgTable.style.visibility = 'hidden';		

	var cords = getPos(referralObj);
	var leftStr =  (cords.x-430) + "px";
	var topStr = (cords.y-350) + "px";

	alertTable.style.left=leftStr;
	alertTable.style.top=topStr;
	actual_product=id;
	
	if(!alertTable)
		return false;
	alertTable.style.visibility = 'visible';
	return;
}

function hideMaxAlert()
{
	var alertTable = (document.getElementById('redirectDiv'));
	if(!alertTable)
		return false;
	alertTable.style.visibility = 'hidden';
	return;
}

function verify(lngslt)
  {
	var error = "";
	var yourName=document.getElementById('yourname');
	var yourEmail=document.getElementById('yourmail');
	var emailTo=document.getElementById('mail_addresses');
	var EmailValid=checkMail(yourEmail.value);
	if (yourName.value.length==0) error += "Please enter your name\n";
	if (yourEmail.value.length==0) error += "Please enter your email address\n";
	if (emailTo.value.length==0) error += "Please enter at least one email address for the destination field\n";
	if (!EmailValid)	error += "Please enter a valid email address\n";

	if (error!="") alert(error);
			  else mailit(lngslt);
  }

function mailit(lngslt)
  {
	var textBlue=document.getElementById('redirectBlueNote');
	var contentDiv=document.getElementById('redirectPopupTextContainer');
	var yourName=document.getElementById('yourname');
	var yourEmail=document.getElementById('yourmail');
	var mailAddresses=document.getElementById('mail_addresses');
	
	http = new createRequestObject();
	posting = '&product='+actual_product+'&things=';
	posting += yourName.value+')';
	posting += '('+yourEmail.value+')';
	posting += '('+mailAddresses.value;
	
	http.onreadystatechange = function()
	{
		 if(http.readyState==4)
		{
			textBlue.innerHTML=http.responseText;
			contentDiv.style.display='none';
			yourName.value='';
			yourEmail.value='';
			mailAddresses.value='';
		}
	}
	http.open('GET','/mailing_product.php?lngslt='+lngslt+''+posting);
	http.send(null);
  }

function makeRequest_product(url, lngslt) 
{
	var textBlue=document.getElementById('redirectsaveBlueNote');
	var contentDiv=document.getElementById('redirectsavePopupTextContainer');
	var userName=document.getElementById('username');
	var userPass=document.getElementById('password');
	var loginMenu=document.getElementById('login_menu');
	
	http = new createRequestObject();

        http.onreadystatechange = function (  ) {
            if (http.readyState == 4) {

			 textBlue.innerHTML=http.responseText;
			 contentDiv.style.display='none';
			 userName.value='';
			 userPass.value='';
			 loginMenu.style.visibility='hidden';
			}
        }
     http.open('GET', url, true);
     http.send(null);
} 
  
function send_product(lngslt)
{
	var userName=document.getElementById('username');
	var userPass=document.getElementById('password');
	
	params =  "&product="+actual_save_product+"&username=" + userName.value + "&password=" + userPass.value;
	makeRequest_product("/login_and_save_product.php?lngslt="+lngslt+""+params, lngslt);
 }
 
 function showSaveMaxAlert(lngslt, id, msg)
{
	id=id.toString();
	var prdsave = "prdsave_"+id;
	var referralObj = document.getElementById(prdsave);
	var loggedIn = (document.getElementById('ysn_logged_in'));

	var alertMsgTable = (document.getElementById('redirectmsgDiv'));
	var alertSaveTable = (document.getElementById('redirectsaveDiv'));
	var alertTable = (document.getElementById('redirectDiv'));
	var blueText = (document.getElementById('redirectsaveBlueNote'));
	var contentText = (document.getElementById('redirectsavePopupTextContainer'));
	actual_save_product=id;	

	if(loggedIn && loggedIn.value==1)
	{
			makeRequest_product("/login_and_save_product.php?lngslt="+lngslt+"&product="+actual_save_product);
		contentText.style.display=='none';
	} 
	else
	{
		if(blueText.innerHTML!=msg)
			blueText.innerHTML=msg;
		
		if(contentText.style.display=='none')
			contentText.style.display='block';
		
	}	
	
	document.body.onclick=hideSaveMaxAlert;
	if(alertTable.style.visibility == 'visible')
			alertTable.style.visibility = 'hidden';
	if(alertMsgTable.style.visibility == 'visible')
		alertMsgTable.style.visibility = 'hidden';		

	var cords = getPos(referralObj);
	var leftStr =  (cords.x-430) + offsetX + "px";
	var topStr = (cords.y-350) + offsetY + "px";

	alertSaveTable.style.left=leftStr;
	alertSaveTable.style.top=topStr;
	
	if(!alertSaveTable)
		return false;
	alertSaveTable.style.visibility = 'visible';
	return;
}
 
 function hideMsgMaxAlert()
{
	var alertMsgTable = (document.getElementById('redirectmsgDiv'));
	if(!alertMsgTable)
		return false;
	alertMsgTable.style.visibility = 'hidden';
	return;
}

function hideSaveMaxAlert()
{
	var alertSaveTable = (document.getElementById('redirectsaveDiv'));
	if(!alertSaveTable)
		return false;
	alertSaveTable.style.visibility = 'hidden';
	return;
}


function checkmessage(lngslt)
  {
	var error = "";
	var questionProduct=document.getElementById('question_product');
	var subjectProduct=document.getElementById('qstsubj');
	if (subjectProduct.value.length==0) error += "The subject box can't be empty\n";
	if (questionProduct.value.length==0) error += "The message box can't be empty\n";
	if (error!="") alert(error);
			  else msg_product1(lngslt);
  } 
  
function msg_product1(lngslt)
{
	var questionProduct=document.getElementById('question_product');
	var subjectProduct=document.getElementById('qstsubj');
	
//	params =  "/product/"+actual_msg_product+"/qsubj/"+subjectProduct.value+"/qprod/"+questionProduct.value;
//	makeRequest_prdmsg("/msg_product/lngslt/"+lngslt+""+params, lngslt);
	$.ajax({type:"POST", url:"/msg_product/lngslt/"+lngslt, data:"product="+actual_msg_product+"&qsubj="+subjectProduct.value+"&qprod="+questionProduct.value});

	hideMsgMaxAlert();
 }
 
 function msg_product(lngslt)
{
	var msgUserName=document.getElementById('msgusername');
	var msgUserPass=document.getElementById('msgpassword');
	
	params =  "/product/"+actual_msg_product+"/username/" + msgUserName.value + "/password/" + msgUserPass.value;
	makeRequest_prdmsg("/login_and_msg_product/lngslt/"+lngslt+""+params, lngslt);
 }
 
 function open_remember(obj) {
	var dv=document.createElement("div");
	var infoText=(obj.nextSibling.nodeType==1) ? obj.nextSibling : obj.nextSibling.nextSibling;
	dv.id="rem_details";
	dv.className="remdiv";
	dv.innerHTML=infoText.innerHTML;
	dv.style.position="absolute";
	dv.style.paddingLeft="2px";
	dv.style.paddingRight="2px";
	dv.style.paddingTop="2px";
	dv.style.paddingBottom="2px";
	dv.style.left=parseInt(findPosX(obj)-210)+"px";
	dv.style.top=parseInt(findPosY(obj)-80)+"px";
	dv.style.borderStyle="solid";
	dv.style.borderWidth="1px";
	dv.style.borderColor="#78C4F5";
	dv.style.width="200px";
	dv.style.backgroundColor="#FFCA1C";
	document.body.appendChild(dv);
}


function real_collapse() {
	document.body.removeChild(document.getElementById('rem_details'));
}

function collapse_remember() {
	setTimeout("real_collapse()",0);
}

 function formVerifier(formObj) {
	formObj = document.post_form;
	if (formObj.post_subject.value.length<4) { alert(msgSub); return false; }
	else if (formObj.post_message.value.length<10) { alert(msgMsg); return false; }
	return true;
 }

 function submitMessage() {
	var params = 'sender_id=' + as_user_id + '&recipient=' + document.getElementById('post_recipient').value;
	vrfAndSbmtMsg('/as_verify_username.php', params);
 }

 function deleteSelectedPosts() {
	if (confirm(msgDel))
		formObj = document.post_form.submit();
 }

 function unfriendSelected() {
	if (confirm(frndEnd))
		formObj = document.post_form.submit();
 }
 
 
  function hideFriendDiv() {
	if (onFriendLink == 0 && onFriendDiv == 0) {
		document.getElementById('friend_div').style.visibility = 'hidden';
		if (onPostLink == 0 && onPostDiv == 0)
			document.getElementById('drop_down_bg_div').style.visibility = 'hidden';
	}
 }


 function hidePostDiv() {
	if (onPostLink == 0 && onPostDiv == 0) {
		document.getElementById('post_div').style.visibility = 'hidden';
		if (onFriendLink ==0 && onFriendDiv == 0)
			document.getElementById('drop_down_bg_div').style.visibility = 'hidden';
	}
 }

 function setPos(linkObj, divObj) {
	var position = getPos(linkObj);
	divObj.style.left = (position.x + document.body.scrollLeft) + "px";
	divObj.style.top  = (position.y + 16) + "px";
//	divObj.style.zIndex = "1000";
	divObj.style.visibility = "visible";
	setBgDiv(document.getElementById('drop_down_bg_div'), divObj, linkObj);
 }

 function setBgDiv(divToSet, div2) {
	frameObj = document.getElementById('empty_frame');
	frameObj.style.left   = (div2.offsetLeft - 4) + "px";
	frameObj.style.top    = div2.offsetTop + "px";
	frameObj.style.width  = (div2.offsetWidth + 5) + "px";
	frameObj.style.height = div2.offsetHeight + "px";
	divToSet.style.left       = (div2.offsetLeft - 4) + "px";
	divToSet.style.top        = (div2.offsetTop - 1) + "px";
	divToSet.style.width      = (div2.offsetWidth + 7) + "px";
	divToSet.style.height     = (div2.offsetHeight + 2) + "px";
	divToSet.style.zIndex     = div2.style.zIndex - 1;
	divToSet.style.visibility = "visible";
 }
 
function showPPForm(lngslt, action, link_user)
{
	$('#userrspform').load('/showform.php?lngslt='+lngslt+'&action='+action+'&lusr='+link_user+'&sid='+Math.random(), function()
			       {
					$('#userrspform').show('slow');
					$('#userprfdiv').show('slow');
			       });
}

function showPPUForm(lngslt, action, link_user)
{
	$('#userrspform').load('/showform.php?lngslt='+lngslt+'&action='+action+'&lusr='+link_user+'&sid='+Math.random(), function()
			       {
					$('#userrspform').show('slow');
					$('#userprfdiv').show('slow');
			       });
}

///////////////

var addresses = new Array();
/* var manuallyOrImport = "manually";

 function change_content(lngslt, to, what) {
	if (to=="import") {
		manuallyOrImport = "import";
		document.getElementById('content_adr').innerHTML = document.getElementById('import_add').innerHTML;
	}
	else {
		manuallyOrImport = "manually";
		document.getElementById('content_adr').innerHTML = document.getElementById('manually_add').innerHTML;
	}

	document.getElementById('content_adr').parentNode.style.height = "262px";
	document.getElementById('request_div').style.display = "block";
	document.getElementById('request_button').innerHTML = "<img src='http://www.travelgrove.com/community/images/check_and_request.gif' alt='Check now &amp; request to connect' onclick=\"add_contacts('" + lngslt + "')\">";
	document.getElementById('request_button').style.display = "block";
	document.getElementById('unregPeople').style.display = "none";
	document.getElementById('foundContacts').style.display = "none";
	while (addresses.length>0) addresses.pop();
 }
*/

 function tryAgain() {
	document.getElementById('content_adr').innerHTML = document.getElementById('import_add').innerHTML;
 }


 function check_email_fi(e) {
	var re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
	if (e.match(re_two)) return true;
	return false;
 }

/*
 function add_from_manually(lngslt) {
	var ok = true;
	_elements = document.getElementById('content_adr').getElementsByTagName('input');
	for (i=0; i<_elements.length; i++) {
		var _element = _elements[i].value.toLowerCase();
		if (_element=="") continue;
		if (check_email_fi(_element)) {
			if (!inArray(_element)) addresses.push(_element);
		}
		else {
			_elements[i].style.color = "red";
			ok = false;
		}
	}

	if (ok && addresses.length>0) {
		var _param = "";
		for (i=0; i<addresses.length; i++) _param += addresses[i] + ",";
		_param = "addresses=" + escape(_param.substr(0, _param.length-1)) + "&lngslt=" + lngslt;
		if (document.getElementById('ysn_request').checked==true) _param += "&send_automatically=y";
															 else _param += "&send_automatically=n";
		document.getElementById('content_adr').innerHTML = "Please wait...";
		makeRequest("/abimporter_inviter_ajax.php", _param);
	}
 }
*/

 function import_contacts(lngslt) {
	if (!check_email_fi(document.getElementById('user_email').value)) { alert("Wrong email address!"); return false; }
	var _param = "email=" + document.getElementById('user_email').value + "&pass=" + document.getElementById('pass').value + "&lngslt=" + lngslt;
	document.getElementById('content_adr').innerHTML = invConn;
	makeRequest("/abimporter_ajax.php", _param);
 }


 function add_contacts(lngslt) {
	if (manuallyOrImport == "import") import_contacts(lngslt);
	else add_from_manually(lngslt);
 }


 function inArray(anAddress) {
	for (var i=0; i<addresses.length; i++)
		if (addresses[i]==anAddress) return true;
	return false;
 }

/*
 function invite(alreadyFriends, alreadyMembers, notYetMembers) {
	document.getElementById('content_adr').parentNode.style.height = "auto";
	document.getElementById('request_div').style.display = "none";
	document.getElementById('ysn_request').checked = "true";
	document.getElementById('content_adr').innerHTML = document.getElementById('inviter').innerHTML;

	if (alreadyFriends[0]!="unavailable") {
		document.getElementById('foundFriends').style.display = "block";
		for (i=0; i<alreadyFriends.length; i++)
			document.getElementById('foundFriends').innerHTML += " &bull; " + alreadyFriends[i] + "<br>";
	}
	if (alreadyMembers[0]!="unavailable") {
		document.getElementById('foundContacts').style.display = "block";
		for (i=0; i<alreadyMembers.length; i++)
			document.getElementById('foundContacts').innerHTML += " &bull; " + alreadyMembers[i] + "<br>";
	}
	if (notYetMembers[0]!="unavailable") {
		document.getElementById('unregPeople').style.display = "block";
		document.getElementById('request_button').innerHTML = "<img src='http://www.travelgrove.com/community/images/invite_selected_friends.gif' alt='invite selected friends' style='margin-bottom: 5px;' onclick='inviteSelectedFriends()'>";
		document.getElementById('unregPeople').innerHTML += "<div class='checker'><a href='javascript: checkAll()'>" + invChckAll + "</a> &nbsp; <a href='javascript: uncheckAll()'>" + invUnChckAll + "</a></div>";
		for (i=0; i<notYetMembers.length; i++)
			document.getElementById('unregPeople').innerHTML += "<input type='checkbox' value='"+notYetMembers[i]+"'> " + notYetMembers[i] + "<br>";
		document.getElementById('unregPeople').innerHTML += "<div class='checker'><a href='javascript: checkAll()'>" + invChckAll + "</a> &nbsp; <a href='javascript: uncheckAll()'>" + invUnChckAll + "</a></div>";
	}
	else document.getElementById('request_button').innerHTML = "";
 }
*/
/*
 function inviteSelectedFriends() {
	var selAdrTxt = "";
	var selAdrArray = document.getElementById('unregPeople').getElementsByTagName("input");
	for (i=0; i<selAdrArray.length; i++)
		if (selAdrArray[i].checked) selAdrTxt += selAdrArray[i].value + ",";
	var _param = "addresses=" + escape(selAdrTxt.substr(0, selAdrTxt.length-1));
	_param += "&send_automatically=y";
	makeRequest("/abimporter_inviter_ajax.php", _param);
 }
*/
/*
 function makeRequest(_url, _param) {
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) http_request.overrideMimeType('text/xml');
	}
	else if (window.ActiveXObject) { // IE
		try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e) {
			try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {}
		}
	}

	if (!http_request) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; }
	
	http_request.onreadystatechange = function () {
		if (http_request.readyState == 4) {
			var responseText = http_request.responseText;
			if (_url=="/abimporter_ajax.php") {
				if (responseText.search("Error")==-1) {
					var importedAddresses = responseText.split(" ");
					for (i=0; i<importedAddresses.length; i++)
						if (!inArray(importedAddresses[i])) addresses.push(importedAddresses[i]);
					if (i>0) {
						var _param = "";
						for (i=0; i<addresses.length; i++) _param += addresses[i] + ",";
						_param = "addresses=" + escape(_param.substr(0, _param.length-1));
						if (document.getElementById('ysn_request').checked==true) _param += "&send_automatically=y";
																			 else _param += "&send_automatically=n";
						document.getElementById('content_adr').innerHTML = "Downloading contacts...";
						makeRequest("/abimporter_inviter_ajax.php", _param);
					}
				}
				else document.getElementById('content_adr').innerHTML = responseText;
			}
			// invitation
			else {
				// invite people without asking
				if (responseText.search('\*')==-1) { // problem!!!
					scroll(0,0);
					document.getElementById('content_adr').innerHTML = responseText;
					document.getElementById('request_div').style.display = "none";
					document.getElementById('request_button').style.display = "none";
				}
				// invite people with asking
				else {
					var alreadyFriends = (responseText.split("*"))[0];
					var alreadyMembers = (responseText.split("*"))[1];
					var notYetMembers  = (responseText.split("*"))[2];
					invite(alreadyFriends.split(","), alreadyMembers.split(","), notYetMembers.split(","));
				}
			}
		}
	}

	http_request.open("GET", _url + "?" + _param, true);
	http_request.send(null);
 }
*/
/*
 function checkAll() {
	var chkElements = document.getElementById('unregPeople').getElementsByTagName('input');
	for (i=0; i<chkElements.length; i++)
		if (chkElements[i].type=="checkbox") chkElements[i].checked = true;
 }

 function uncheckAll() {
		var chkElements = document.getElementById('unregPeople').getElementsByTagName('input');
	for (i=0; i<chkElements.length; i++)
		if (chkElements[i].type=="checkbox") chkElements[i].checked = false;
 }
*/

 // class for getting the windows inner (currently visible) width and height
 /*function WindowSize() {
	var wWidth = 0, wHeight = 0;
	this.getMaxWidth = function () { return wWidth; }
	this.getMaxHeight = function () { return wHeight; }
	this.getScrollWidth = getScrollWidth;
	this.getScrollHeight = getScrollHeight;
	calcSize();


	function calcSize() {
		if (typeof( window.innerWidth )=="number") {
			//Non-IE
			wWidth = window.innerWidth;
			wHeight = window.innerHeight;
		} else if( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight) ) {
			//IE 6+ in 'standards compliant mode'
			wWidth = document.documentElement.clientWidth;
			wHeight = document.documentElement.clientHeight;
		} else if( document.body && (document.body.clientWidth || document.body.clientHeight) ) {
			//IE 4 compatible
			wWidth = document.body.clientWidth;
			wHeight = document.body.clientHeight;
		}
	}

	function getScrollWidth() {
		var w = window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft;
		return w ? w : 0;
	}

	function getScrollHeight() {
		var h = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
		return h ? h : 0;
	}
 }
 */
 
 function inviteInsert() {
	var chkElements = document.getElementById('invite_mails').getElementsByTagName('input');
	for (i=0; i<chkElements.length; i++)
		if (chkElements[i].type=="checkbox" && chkElements[i].checked == true) {
			if (document.getElementById('recipients').value.length>0)
				document.getElementById('recipients').value += ', ' + chkElements[i].value;
			else
				document.getElementById('recipients').value = chkElements[i].value;
		}
 }

 function showInviter(lngslt) {
	document.getElementById('invite_switch').innerHTML = invTryAn + " <a href=\"javascript: tryAnotherAccount('"+lngslt+"')\">" + invClckHr + "</a>.";
	document.getElementById('invite_import').style.display = "inline";
 }

 function tryAnotherAccount(lngslt) {
	document.getElementById('invite_mails').innerHTML = "";
	document.getElementById('invite_mails').style.height = "auto";
	document.getElementById('invite_mails').style.border = "none";

	document.getElementById('invite_commands').style.display = "none";
	document.getElementById('invite_button').style.display = "none";

	document.getElementById('invite_import').innerHTML = "<form method='POST' onsubmit=\"inviteContacts('" + lngslt + "'); return false;\">" + invTxt1 + ":<br><div class='imp_part_left'>" + invYrMl + ":</div><div class='imp_part_right'><input type='text' name='user_email' id='user_email'></div><div class='imp_part_left'>" + invYrPass + ":</div><div class='imp_part_right'><input type='password' name='pass' id='pass'></div><input type='submit' value='" + invDwnld2 + "'></form>";
 }

 function inviteContacts(lngslt) {
	if (!check_email_fi(document.getElementById('user_email').value)) { alert(invWrngMl); return false; }
	var params = "email=" + document.getElementById('user_email').value + "&pass=" + document.getElementById('pass').value + "&lngslt=" + lngslt;
	document.getElementById('invite_import').innerHTML = "";
	document.getElementById('invite_mails').innerHTML = invDwnld;
	document.getElementById('invite_mails').style.height = "200px";
	document.getElementById('invite_mails').style.border = "1px solid #9ba5af";
	makeRequestZ("/abimporter_ajax.php", params, "invite");
 }

 function inviteAppend(emailToAppend, i) {
	document.getElementById('invite_mails').innerHTML += "<input type='checkbox' checked='true' id='inv"+i+"' value='"+emailToAppend+"'> <label for='inv"+i+"'>" + emailToAppend + "</label><br>";
 }

 function makeRequestZ(_url, _param, _invite) {
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) http_request.overrideMimeType('text/xml');
	}
	else if (window.ActiveXObject) { // IE
		try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e) {
			try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {}
		}
	}

	if (!http_request) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; }
	
	http_request.onreadystatechange = function () {
		if (http_request.readyState == 4) {
			var responseText = http_request.responseText;
			if (_url=="/abimporter_ajax.php" && _invite=="invite") {
				if (responseText.search("Error")==-1) {
					var importedAddresses = responseText.split(" ");
					document.getElementById('invite_mails').innerHTML = "";
					for (i=0; i<importedAddresses.length; i++)
						inviteAppend(importedAddresses[i], i);
					if (i>0) {
						document.getElementById('invite_commands').style.display = "inline";
						document.getElementById('invite_button').style.display = "inline";
					}
				}
				else {
					document.getElementById('invite_mails').style.height = "auto";
					document.getElementById('invite_mails').style.border = "none";
					document.getElementById('invite_mails').innerHTML = responseText.replace(/\s?<a\s.+<\/a>!?/, "");

					document.getElementById('invite_commands').style.display = "none";
					document.getElementById('invite_button').style.display = "none";
				}
			}
		}
	}

	http_request.open("GET", _url + "?" + _param, true);
	http_request.send(null);
 }


 function inviteCheckAll() {
	var chkElements = document.getElementById('invite_mails').getElementsByTagName('input');
	for (i=0; i<chkElements.length; i++)
		if (chkElements[i].type=="checkbox") chkElements[i].checked = true;
 }

 function inviteUncheckAll() {
	var chkElements = document.getElementById('invite_mails').getElementsByTagName('input');
	for (i=0; i<chkElements.length; i++)
		if (chkElements[i].type=="checkbox") chkElements[i].checked = false;
 }

 function vrfAndSbmtMsg(url, params) {
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) http_request.overrideMimeType('text/xml');
	}
	else if (window.ActiveXObject) { // IE
		try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e) {
			try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {}
		}
	}

	if (!http_request) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; }
	
	http_request.onreadystatechange = function () {
		if (http_request.readyState == 4) {
			if (http_request.responseText=="error") alert(msgErr);
			else document.post_form.submit();
		}
	}

	http_request.open("GET", url + "?" + params, true);
	http_request.send(null);
 }
 
function lastMsgChat(lngslt)
{
	http = new createRequestObject();
	
	http.onreadystatechange = function()
	{
		if(http.readyState==4)
		{
			var chatroom = document.getElementById('chatroom');
			chatroom.innerHTML='';
			chatroom.innerHTML=http.responseText;
		}
	}
	http.open('GET','/lastmsgcr.php?lngslt='+lngslt+'&sid='+Math.random());
	http.send(null);
}

function show_img(img, obj, name, width, height)
{
	image = new Image();
	image.src=img;	
	var dv=document.createElement("div");
	var text=(obj.parentNode.nextSibling.nodeType==1) ? obj.parentNode.nextSibling : obj.parentNode.nextSibling.nextSibling;
	dv.id="rem_details";
	dv.innerHTML="<div style='float:left; width:150px; border-right:1px dotted #4E5A5A; margin-right:5px;'><img src='"+image.src+"' width='"+width+"' height='"+height+"' /><br/><br/>"+name+"</div>"+text.innerHTML;
	dv.style.font="700 12px Helvetica,arial,sans-serif;";
	dv.style.color="#4E5A5A";
	dv.style.position="absolute";
	dv.style.paddingLeft="2px";
	dv.style.paddingRight="2px";
	dv.style.paddingTop="2px";
	dv.style.paddingBottom="2px";
	dv.style.left=parseInt(findPosX(obj)+55)+"px";
	dv.style.top=parseInt(findPosY(obj)-150)+"px";
	dv.style.borderStyle="solid";
	dv.style.borderWidth="1px";
	dv.style.borderColor="#99A6B2";
	dv.style.width="300px";
	dv.style.height="140px";
	dv.style.textAlign="center";
	dv.style.background="#fff url(/images/ajax_loader_big.gif) no-repeat 61px 10px";
	document.body.appendChild(dv);	
}

 function open_remember1(obj) {
	var dv=document.createElement("div");
	var infoText=(obj.nextSibling.nodeType==1) ? obj.nextSibling : obj.nextSibling.nextSibling;
	dv.id="rem_details";
	dv.className="remdiv";
	dv.innerHTML=infoText.innerHTML;
	dv.style.position="absolute";
	dv.style.paddingLeft="2px";
	dv.style.paddingRight="2px";
	dv.style.paddingTop="2px";
	dv.style.paddingBottom="2px";
	dv.style.left=parseInt(findPosX(obj))+"px";
	dv.style.top=parseInt(findPosY(obj)-110)+"px";
	dv.style.borderStyle="solid";
	dv.style.borderWidth="3px";
	dv.style.borderColor="#77C4F2";
	dv.style.width="200px";
	dv.style.backgroundColor="#fff";
	document.body.appendChild(dv);
}

 function open_remember2(obj) {
	var dv=document.createElement("div");
	var infoText=(obj.nextSibling.nodeType==1) ? obj.nextSibling : obj.nextSibling.nextSibling;
	dv.id="rem_details";
	dv.className="remdiv";
	dv.innerHTML=infoText.innerHTML;
	dv.style.position="absolute";
	dv.style.paddingLeft="2px";
	dv.style.paddingRight="2px";
	dv.style.paddingTop="2px";
	dv.style.paddingBottom="2px";
	dv.style.left=parseInt(findPosX(obj)-80)+"px";
	dv.style.top=parseInt(findPosY(obj)+110)+"px";
	dv.style.borderStyle="solid";
	dv.style.borderWidth="3px";
	dv.style.borderColor="#77C4F2";
	dv.style.width="200px";
	dv.style.backgroundColor="#fff";
	document.body.appendChild(dv);
}

function acceptIndividualShopRulles(obj)
{
	var divMare=obj.parentNode;
	var chkbox=document.getElementById('shopsterms');
	var divVecin=(divMare.previousSibling.nodeType==1) ? divMare.previousSibling : divMare.previousSibling.previousSibling;
	var chkbox=(divVecin.childNodes[0].nodeType==1) ? divVecin.childNodes[0] : divVecin.childNodes[1];
	if(!chkbox.checked)
	{
		alert(RegRules);
		return(false);
	}
}

function showReplyForm(obj)
{
	$(obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode).fadeOut('slow',
												    function(){
													$('#replyForm').fadeIn('slow');
													});
}

var themes=[
	    {background:"#EDECE9", text:"#634047", link:"#088253", border:"#D3D2CF", content:"#FFFFFF", title:"#634047", img:"/images/themes/1.gif", bgtile: 0},
	    {background:"#EBEBEB", text:"#333333", link:"#990000", border:"#DFDFDF", content:"#FFFFFF", title:"#333333", img:"/images/themes/2.gif", bgtile: 0},
	    {background:"#BADFCD", text:"#0C3E53", link:"#FF0000", border:"#F2E195", content:"#FFFFFF", title:"#0C3E53", img:"/images/themes/3.gif", bgtile: 0},
	    {background:"#9AE4E8", text:"#333333", link:"#0084B4", border:"#BDDCAD", content:"#FFFFFF", title:"#333333", img:"/images/themes/4.gif", bgtile: 0},
	    {background:"#352726", text:"#3E4415", link:"#D02B55", border:"#99CC33", content:"#FFFFFF", title:"#3E4415", img:"/images/themes/5.gif", bgtile: 0},
	    {background:"#709397", text:"#333333", link:"#FF3300", border:"#A0C5C7", content:"#FFFFFF", title:"#333333", img:"/images/themes/6.gif", bgtile: 0},
	    {background:"#8B542B", text:"#333333", link:"#9D582E", border:"#99CC33", content:"#FFFFFF", title:"#EADEAA", img:"/images/themes/7.gif", bgtile: 0},
	    {background:"#C6E2EE", text:"#663B12", link:"#1F98C7", border:"#DAECF4", content:"#FFFFFF", title:"#663B12", img:"/images/themes/8.gif", bgtile: 0},
	    {background:"#0099B9", text:"#3C3940", link:"#0099B9", border:"#95E8EC", content:"#FFFFFF", title:"#3C3940", img:"/images/themes/9.gif", bgtile: 0},
	    {background:"#1A1B1F", text:"#666666", link:"#2FC2EF", border:"#252429", content:"#FFFFFF", title:"#666666", img:"/images/themes/10.gif", bgtile: 0},
	    {background:"#642D8B", text:"#3D1957", link:"#FF0000", border:"#7AC3EE", content:"#FFFFFF", title:"#3D1957", img:"/images/themes/11.gif", bgtile: 1},
	    {background:"#FF6699", text:"#362720", link:"#B40B43", border:"#E5507E", content:"#FFFFFF", title:"#362720", img:"/images/themes/12.gif", bgtile: 1}
	    ]

$(function(){
	if(typeof($(document).pngFix)!='undefined')
		$(document).pngFix();
		
	$('<b class="line1prop menuline1">&nbsp;</b><b class="line2prop menuline2">&nbsp;</b><b class="line3prop menuline3">&nbsp;</b>').insertBefore('div.menucontent');
	$('<b class="line1prop smallrectangleline1">&nbsp;</b><b class="line2prop smallrectangleline2">&nbsp;</b><b class="line3prop smallrectangleline3">&nbsp;</b>').insertBefore('div.smallrectanglecont').insertAfter('div.smallrectanglecont');
	$('<b class="line1prop mediumrectangleline1">&nbsp;</b><b class="line2prop mediumrectangleline2">&nbsp;</b><b class="line3prop mediumrectangleline3">&nbsp;</b>').insertBefore('div.mediumrectanglecont').insertAfter('div.mediumrectanglecont');
	$('<b class="line1prop bigrectangleline1">&nbsp;</b><b class="line2prop bigrectangleline2">&nbsp;</b><b class="line3prop bigrectangleline3">&nbsp;</b>').insertBefore('div.bigrectanglecont');
	$('<b class="line1prop bigrectangleline1">&nbsp;</b><b class="line2prop bigrectangleline2">&nbsp;</b><b class="line3prop bigrectangleline3">&nbsp;</b>').insertAfter('div.bigrectanglecont');

	if(typeof($.farbtastic)!='undefined')
	{	
		var f = $.farbtastic('#picker');
		$('#user_profile_background_color').change(function() {
			if(this.value.length==7 || this.value.length==4)
				document.body.style.backgroundColor = this.value;
			});
		var p = $('#picker').css('display', 'none');
		var fp = $('#fadedpicker').css('display', 'block');
		var selected;
		var selectedtheme;
	
		$('.colorwell')
			.each(function () { f.linkTo(this); $(this).css('opacity', 0.75); })
			.focus(function() {
				if (selected)
					$(selected).css('opacity', 0.75).removeClass('colorwell-selected');
				
				var inpObj = this;
				f.linkTo(function(c) {
					inpObj.value = c;
					inpObj.style.backgroundColor = c;
					updateColors(inpObj.id, c);
				});
				fp.css('display', 'none');
				p.css('display', 'block');
				$(selected = this).css('opacity', 1).addClass('colorwell-selected');
			})
			.blur( function() {
			  $(this).val($(this).val().toUpperCase());
			 })
			.keyup(function(){
				if ($(this).val().indexOf('#') != 0) { $(this).val('#' + $(this).val()); }
				$(this).val($(this).val().toUpperCase());
				$(this).css('background', $(this).val());
				updateColors(this.id, $(this).val());
			});
		$('#uudesign').click(function(){$('#styleprofile').slideToggle('slow')});
		$('#urdesign').click(function(){
				var a=confirm('Do you realy want to reset the style of your profile?');
				   if(a) return true;
				   else return false;
				});
		$('#bcancel').click(function(){$(this).parent().parent().parent().slideToggle('slow');});
		$("#prfthemes img").each(function(idx) {
			$(this).click(function(){
				selectTheme(idx);
				if(selectedtheme)
					$(selectedtheme).css('border', '1px solid #FFF').removeClass('selectedtheme');				
				$(selectedtheme = this).addClass('selectedtheme');
				$('a#bgtheme span').css('background', 'url('+$(selectedtheme).attr('src')+') no-repeat;');
			}).mouseover(function(){
				$(this).css('border', '1px solid #4E5A5A');
			}).mouseout(function(){
				if(!$(this).hasClass('selectedtheme'))
					$(this).css('border', '1px solid #FFF');
			});
		});
		$('#chgbi').click(function(){
			if($('#prfcolors').css('display')=='block')
				$('#prfcolors').css('display', 'none');
			$('#prfbgimg').slideToggle('slow');	
//			$('#prfbgimg').css('display', 'block');
		});
		$('#chgclrs').click(function(){
			if($('#prfbgimg').css('display')=='block')
				$('#prfbgimg').css('display', 'none');
			$('#prfcolors').slideToggle('slow');
//			$('#prfcolors').css('display', 'block');
		});
		$('input#user_profile_background_tile').click(function(){
			if($('input#user_profile_background_tile').get(0).checked==true)
				$('body').css('background-repeat', 'repeat').css('background-attachment', 'scroll');
			else if($('input#user_profile_background_tile').get(0).checked==false)
				$('body').css('background-repeat', 'no-repeat').css('background-attachment', 'fixed');
		});
		var themeBgImg='';
		
		$('a#nobgtheme').click(function(){
			themeBgImg = $('body').css('background-image');
			$('body').css('background-image', 'none');
			$('input#user_profile_background_image').val('0');
			$('input#user_profile_background_imgurl').val('');
			$('input#user_profile_background_tile').get(0).checked=false;
			return false;
		});
		
		$('a#bgtheme').click(function(){
			if($('body').css('background-image')=='none')
			{
				$('body').css('background-image', themeBgImg);
				$('input#user_profile_background_image').val('1');
				var picture_url=$('a#bgtheme span').css('background-image').split("/");
				var picture_img=picture_url[5].split(")");
				var picture_file=picture_img[0].split("s");
				$('input#user_profile_background_imgurl').val('/'+picture_url[3]+'/'+picture_url[4]+'/'+picture_file[0]+picture_file[1]);
			}
			return false;
		});
	}
	else
	{
		$('#uudesign').click(function(){
			var a=confirm(q);
			if(a) return true;
			else return false;
			});
	}	
});

function selectTheme(i) {
	var backgroundImage='';
	if(themes[i].bgtile==1)
	{
		backgroundImage=' url('+themes[i].img+') repeat';
		$('input#user_profile_background_tile').get(0).checked=true;
	}
	else
	{
		backgroundImage=' url('+themes[i].img+') no-repeat fixed';
		$('input#user_profile_background_tile').get(0).checked=false;
	}

	$('body').css('background', themes[i].background+backgroundImage);
	$('body, #login_menu').css('color', themes[i].text);
	$('a, div.linecontprop h2').css('color', themes[i].link);
	$('strong.boxtitle').css('color', themes[i].title);
	$('b.line1prop').css('background-color', themes[i].border);
	$('b.line2prop').css('border-left', '2px solid '+themes[i].border);
	$('b.line2prop').css('border-right', '2px solid '+themes[i].border);
	$('b.line3prop').css('border-left', '1px solid '+themes[i].border);
	$('b.line3prop').css('border-right', '1px solid '+themes[i].border);
	$('div.linecontprop, .menucontprop').css('border-right', '1px solid '+themes[i].border);
	$('div.linecontprop, .menucontprop').css('border-left', '1px solid '+themes[i].border);
	$('div.submenu').css('border-top', '1px solid '+themes[i].border);
	$('div.submenu').css('border-bottom', '1px solid '+themes[i].border);
	$('b.line2prop').css('background-color', themes[i].content);
	$('b.line3prop').css('background-color', themes[i].content);
	$('div.linecontprop, .menucontprop').css('background-color',themes[i].content);
	$('div.submenu').css('background',themes[i].content);
	$('input#user_profile_background_color').val(themes[i].background).css('background', themes[i].background);
	$('input#user_profile_link_color').val(themes[i].link).css('background', themes[i].link);
	$('input#user_profile_text_color').val(themes[i].text).css('background', themes[i].text);
	$('input#user_profile_title_color').val(themes[i].title).css('background', themes[i].title);
	$('input#user_profile_border_color').val(themes[i].border).css('background', themes[i].border);
	$('input#user_profile_contentbg_color').val(themes[i].content).css('background', themes[i].content);	
	$('input#user_profile_background_imgurl').val(themes[i].img);
	$('input#user_profile_background_image').val('1');
}

function updateColors(obj, valuecolor)
{
	switch(obj){
			case 'user_profile_background_color':
				$('body').css('background-color', valuecolor);
				break;
			case 'user_profile_text_color':
				$('body, #login_menu').css('color', valuecolor);
				break;
			case 'user_profile_link_color':
				$('a, div.linecontprop h2').css('color', valuecolor);
				break;
			case 'user_profile_title_color':
				$('.boxtitle').css('color', valuecolor);
				break;
			case 'user_profile_border_color':
				$('.line1prop').css('background-color', valuecolor);
				$('.line2prop').css('border-left', '2px solid '+valuecolor);
				$('.line2prop').css('border-right', '2px solid '+valuecolor);
				$('.line3prop').css('border-left', '1px solid '+valuecolor);
				$('.line3prop').css('border-right', '1px solid '+valuecolor);
				$('.linecontprop, .menucontprop').css('border-right', '1px solid '+valuecolor);
				$('.linecontprop, .menucontprop').css('border-left', '1px solid '+valuecolor);
				$('.submenu').css('border-top', '1px solid '+valuecolor);
				$('.submenu').css('border-bottom', '1px solid '+valuecolor);
				break;
			case 'user_profile_contentbg_color':
				$('.line2prop').css('background-color', valuecolor);
				$('.line3prop').css('background-color', valuecolor);
				$('.linecontprop, .menucontprop').css('background-color',valuecolor);
				$('.submenu').css('background',valuecolor);
				break;
		}
}

function deleteAcc(msg)
{
	var a = confirm(msg);
	
	if(!a)
		return false;
	else
		return true;
}
