// AJAX load content
function loadContent1(id) {
			document.getElementById('subCat3').className='subCat3On';
			$('#subCat2').hide('fast',hideContent1(id));
	}

function hideContent1(id)
{
	$("#subCat2").load(id,'',showContent1);
}

function showContent1()
{
	$("#subCat2").show('normal');
	document.getElementById('subCat3').className='subCat3Off';
}

$(function() {
	$('.bookmarks a').tooltip({
		track: true,
		delay: 0,
		showURL: false,
		showBody: " - ",
		fade: 250
	});
});

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
	
//product_page.php

	function CmntValidate(){
		if (document.FCmnt.CName.value==""){
			alert("Please enter your name.")
			document.FCmnt.CName.focus()
			return false
		}
		if (document.FCmnt.CEmail.value != '' && echeck(document.FCmnt.CEmail.value)==false){
			document.FCmnt.CEmail.focus()
			return false
		}
		if (document.FCmnt.COpinion.value==""){
			alert("Please write your comment regarding <?php echo($PTitle); ?>.")
			document.FCmnt.COpinion.focus()
			return false
		}
		if (document.FCmnt.captcha.value==""){
			alert("Please enter image verification to prove that your are not a robot.")
			document.FCmnt.captcha.focus()
			return false
		}
		Load(1); 
	}
	
	function FAQValidate(){
		if (document.FFAQ.QSubmit.alt == "1")
		{
			if (document.FFAQ.QName.value==""){
				alert("Please enter your name.")
				document.FFAQ.QName.focus()
				return false
			}
			if (document.FFAQ.QEmail.value != '' && echeck(document.FFAQ.QEmail.value)==false){
				document.FFAQ.QEmail.focus()
				return false
			}
			if (document.FFAQ.FQ.value==""){
				alert("Please write the question that you want to ask.")
				document.FFAQ.FQ.focus()
				return false
			}
			if (document.FFAQ.Qcaptcha.value==""){
				alert("Please enter image verification to prove that your are not a robot.")
				document.FFAQ.Qcaptcha.focus()
				return false
			}
		}
		else
		{
			if (document.FFAQ.AName.value==""){
				alert("Please enter your name.")
				document.FFAQ.AName.focus()
				return false
			}
			if (document.FFAQ.AEmail.value != '' && echeck(document.FFAQ.AEmail.value)==false){
				document.FFAQ.AEmail.focus()
				return false
			}
			if (document.FFAQ.FA.value==""){
				alert("Please write the question that you want to ask.")
				document.FFAQ.FA.focus()
				return false
			}
			if (document.FFAQ.Acaptcha.value==""){
				alert("Please enter image verification to prove that your are not a robot.")
				document.FFAQ.Acaptcha.focus()
				return false
			}
		}
		Load(1); 
	}
	
	function AddAnswer(QID)
	{
		var AA = document.getElementsByTagName('td');
		for (var I = 0; I < AA.length; I++)
		{
			if (AA[I].id.substring(0,6) ==  "AddAns")
			{
				AA[I].innerHTML="<a class='FAQA1' href='javascript: AddAnswer("+AA[I].id.replace("AddAns","")+");'>Add your answer &gt;&gt;</a>";
			}
		}
		document.getElementById('AddAns'+QID).innerHTML = "<table width='100%' bgcolor='#006000' cellpadding='5' cellspacing='1' border='0'><tr><td class='FAQA2' colspan='2'>Submit your answer</td></tr><tr><td class='FAQBG1' width='220'><strong>Your name:</strong></td><td class='FAQBG2'><input type='text' name='AName' id='AName' maxlength='50' style='width:300px;' />(required)</td></tr><tr><td class='FAQBG1'><strong>Your Email:</strong></td><td class='FAQBG2'><input type='text' name='AEmail' id='AEmail' style='width:300px;' /> (optional)</td></tr><tr><td class='FAQBG1' valign='top'><strong>Your answer:</strong><br />(required)</td><td class='FAQBG2'><textarea class='textbox' name='FA' id='FA' rows='6' style='width:450px;'></textarea><br /><br /></td></tr><tr><td class='FAQBG1' colspan='2'><strong>Image Verfication:</strong></td><tr><td class='FAQBG2' colspan='2'><div style='height:50px; padding:5px 0 0 0;'><div style='float:left; width:180px;'><img id='Acaptchaimg' src='"+ document.getElementById('Qcaptchaimg').src +"'></div><div style='float:left; font-size: 10px;'>Write the code you see on the left image: <input id='Acaptcha' name='Acaptcha' type='text' size='10' /><br /><br />Cannot read the image? <a href='javascript: FAQCaptcha();'>Click Here</a> to generate a new one.</div><div style='float:right; margin:0 0 0 10px;'> <input type='submit' name='ASubmit' id='ASubmit' value=' Submit ' style='height:45px; width:130px; font-weight:bold;' onclick=\"document.getElementById('QSubmit').alt='0'; document.getElementById('QID').value='"+ QID +"'; \" /></div></div></td></tr></table>";
		window.location='#AddAns'+QID;
	}
	
	function FAQCaptcha()
	{
		var lnk = './scripts/secureimage/securimage_show.php?sid=' + Math.random();
		document.getElementById('Qcaptchaimg').src = lnk;
		document.getElementById('Acaptchaimg').src = lnk;
	}
	
	function SelectTab(Tab)
	{
		switch (Tab)
		{
			case "Cmnt":
				document.getElementById('Cmnt1').className = "item7_3";
				document.getElementById('Cmnt2').className = "item7_4";
				document.getElementById('Cmnt3').className = "item7_5";
				
				document.getElementById('FAQ1').className = "item7_6";
				document.getElementById('FAQ2').className = "item7_7";
				document.getElementById('FAQ3').className = "item7_8";
				break;
			case "FAQ":
				document.getElementById('FAQ1').className = "item7_3";
				document.getElementById('FAQ2').className = "item7_4";
				document.getElementById('FAQ3').className = "item7_5";
				
				document.getElementById('Cmnt1').className = "item7_6";
				document.getElementById('Cmnt2').className = "item7_7";
				document.getElementById('Cmnt3').className = "item7_8";
				break;
		}
	}