// JavaScript Document
function checkValue(theForm) {
var reason = "";

  reason += validateUsername(theForm.name);
  reason += validateAct(theForm.act);
  reason += validateAddress(theForm.address);
  reason += validateComment(theForm.comment);
  reason += validateEmail(theForm.mail);
  reason += validatePhone(theForm.phone);
  reason += validatePass(theForm.pass);
  reason += validatePass2(theForm.pass2);
  if (reason != "") {
    alert("Alert for some mistakes.\n" + reason);
    return false;
  }

  return true;
}
function validateEmpty(fld) {
    var error = "";

    if (fld.value.length == 0) {
        fld.style.background = 'Yellow';
        error = "The required field has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;
}
function validateUsername(fld) {
    var error = "";
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter a ( Trade Name ).\n";
//        document.getElementById('na').style.display='block';
    } else if (fld.value.length < 5) {
        fld.style.background = 'Yellow';
        error = "The ( Trade Name ) is the wrong length.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}
function validateAct(fld) {
    var error = "";
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter a ( Activity ).\n";
//        document.getElementById('ac').style.display='block';
    } else {
        fld.style.background = 'White';
    }
    return error;
}
function validateAddress(fld) {
    var error = "";
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter a ( Address ).\n";
//        document.getElementById('ad').style.display='block';
    }  else {
        fld.style.background = 'White';
    }
    return error;
}
function validateComment(fld) {
    var error = "";
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter a Informaion( Comments ) For Your Trade.\n";
//        document.getElementById('co').style.display='block';
    } else {
        fld.style.background = 'White';
    }
    return error;
}

function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}

function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
     if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = 'Yellow';
        error = "Please enter a valid ( email address ).\n";
    }  else {
        fld.style.background = 'White';
    }
    return error;
}
function validatePhone(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');

   if (fld.value == "") {
        error = "You didn't enter a ( Telephone Number).\n";
        fld.style.background = 'Yellow';
//        document.getElementById('ph').style.display='block';
    } else if (isNaN(parseInt(stripped))) {
        error = "The ( Phone Number ) contains illegal characters.\n";
        fld.style.background = 'Yellow';
    } else if (!(stripped.length < 6)) {
        error = "The phone number is the wrong length.\n";
        fld.style.background = 'Yellow';
    }
    return error;
}
function validatePass(fld) {
    var error = "";
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter a ( Password ).\n";
//        document.getElementById('na').style.display='block';
    }else {
        fld.style.background = 'White';
    }
    return error;
}
function validatePass2(fld) {
    var error = "";
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter a ( Password ).\n";
//        document.getElementById('na').style.display='block';
    }else {
        fld.style.background = 'White';
    }
    return error;
}
var slideimages=new Array()
function slideshowimages()
{
  for (i=0;i<slideshowimages.arguments.length;i++)
  {
	  slideimages[i]=new Image()
	  slideimages[i].src=slideshowimages.arguments[i]
  }
}
function no_code(idd)
{
  var regx = document.getElementById(idd).value;

  if(regx.match(/[!$*&<>=+]/i))
    {
      alert("You Can't Use Codes in this Field");
      document.getElementById(idd).value = "";
    }
}
function Inint_AJAX() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
   try { return new XMLHttpRequest();          } catch(e) {} //Native Javascript
   alert("XMLHttpRequest not supported");
   return null;
};

function dochange(src, val) {
     var req = Inint_AJAX();
     req.onreadystatechange = function () {
          if (req.readyState==4 || req.readyState=="complete") 
		  {
               if (req.status==200) 
			   {
                    document.getElementById(src).innerHTML=req.responseText; //retuen value
               }
          }
		  if (req.readyState==0 || req.readyState==1  || req.readyState==2 || req.readyState==3)
 		{
			 var msg="<img src='images/indicator.gif'>";
			 document.getElementById("sub").innerHTML=msg;
 		}
     };
     req.open("GET", "sec.php?data="+src+"&val="+val); //make connection
     req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=windows-1256"); // set Header
     req.send(null); //send value
}

//window.onLoad=dochange('sec', -1);         // value in first dropdown
slideshowimages("images/index_03.jpg","images/index_031.jpg","images/index_032.jpg","images/index_033.jpg")
var slideshowspeed=1900
var whichlink=0
var whichimage=0
function slideit(){
  if (!document.images)
    return
    document.images.slide.src=slideimages[whichimage].src
    whichlink=whichimage

  if (whichimage<slideimages.length-1)
    whichimage++
  else
    whichimage=0
    setTimeout("slideit()",slideshowspeed)
}
function branch(d) {
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}
var xmlHttp
function getVote(int)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Your browser do not support HTTP Request")
		 return
	 }
	var url="pic.php"
	url=url+"?pic="+int
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged()
{
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {
		 document.getElementById("picture").innerHTML=xmlHttp.responseText;
	 }
	 if (xmlHttp.readyState==0 || xmlHttp.readyState==1  || xmlHttp.readyState==2 || xmlHttp.readyState==3)
	 {
		 var msg="<img src='images/loading.gif'>";
		 document.getElementById("picture").innerHTML=msg;
	 }
}
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
	  	// Internet Explorer
		  try
    	{
	    	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    	}
		  catch (e)
	    {
		    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
  	}
	return xmlHttp;
}
function val_se()
{
	var fname=document.getElementById('fname');
	var femail=document.getElementById('femail');
	var temail=document.getElementById('temail');
	if((fname.value=='') || (femail.value=='') || (temail.value==''))
	{
		alert('Please Fill the Blanks');
		return false;
	}
	else
	{
		filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 
		if (filter.test(femail.value) && filter.test(temail.value)) 
		{ 			
		  // Yay! valid 
		  return true; 
		}		
		else
		{
			alert('inValid Email Address');
			femail.focus();
			return false;
		}
	}
}
function val_contact()
{
	var iname=document.getElementById('iname');
	var iemail=document.getElementById('iemail');
	var ititle=document.getElementById('ititle');
	var imsg=document.getElementById('imsg');
	if((iname.value=='') || (iemail.value=='') || (ititle.value=='') || (imsg.value==''))
	{
		alert('Please Fill the Blanks');
		return false;
	}
	else
	{
		filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 
		if (filter.test(iemail.value)) 
		{ 			
		  // Yay! valid 
		  return true; 
		}		
		else
		{
			alert('inValid Email Address');
			iemail.focus();
			return false;
		}
	}
}
function val_advert()
{
//	var ad_nam=document.getElementById('ad_nam');
//	var iemail=document.getElementById('iemail');
	var ad_tit=document.getElementById('ad_tit');
	var ad_msg=document.getElementById('ad_msg');
	if(ad_tit.value=='')
	{
		ad_tit.style.background='Yellow'; 
		alert('Please Fill the Blanks');
		ad_tit.focus();
		return false;
	}
	else if(ad_msg.value=='')
	{
		ad_msg.style.background='Yellow'; 
		alert('Please Fill the Blanks');
		ad_msg.focus();
		return false;
	}
	else
	{
		return true; 		
	}
}
function prnt(d)
{
	if(document.getElementById(d)){document.getElementById(d).style.display='block';}
}
function prrnt(d)
{
		if(document.getElementById(d)){document.getElementById(d).style.display='none';}
}
function add_more()
{
	var txt = "<br><input type=\"file\" name=\"pic_file[]\" size=50><br><input type=text name=\"com[]\" size=50>";
	document.getElementById("dvFile").innerHTML += txt;
}
function bgstyb(id)
{
	var d = document.getElementById(id);
	for (var i = 1; i<=5; i++)
	{
		if (document.getElementById('sa'+i)) {document.getElementById('sa'+i).style.background='';}
	}
	if (d) {d.style.backgroundImage='url(images/bor_02.jpg)';}
}
function SaNews(int)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Your browser do not support HTTP Request")
		 return
	 }	
//	alert(int);
	var url="sec.php"
	url=url+"?saw="+int
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=saChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function saChanged()
{
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {
		 document.getElementById("sanews").innerHTML=xmlHttp.responseText;
	 }
	 if (xmlHttp.readyState==0 || xmlHttp.readyState==1  || xmlHttp.readyState==2 || xmlHttp.readyState==3)
	 {
		 var msg="<center><img src='images/loading.gif'></center>";
		 document.getElementById("sanews").innerHTML=msg;
	 }
}
function SaNeen(int)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Your browser do not support HTTP Request")
		 return
	 }	
//	alert(int);
	var url="sec.php"
	url=url+"?sen="+int
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=saChangeden
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function saChangeden()
{
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {
		 document.getElementById("sanewsen").innerHTML=xmlHttp.responseText;
	 }
	 if (xmlHttp.readyState==0 || xmlHttp.readyState==1  || xmlHttp.readyState==2 || xmlHttp.readyState==3)
	 {
		 var msg="<center><img src='images/loading.gif'></center>";
		 document.getElementById("sanewsen").innerHTML=msg;
	 }
}
function FirstP(int)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Your browser do not support HTTP Request")
		 return
	 }
//	 alert(int);
	var url="sec.php"
	url=url+"?fefed="+int
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=FiChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function FiChanged()
{
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {
		 document.getElementById("feeed").innerHTML=xmlHttp.responseText;
	 }
	 if (xmlHttp.readyState==0 || xmlHttp.readyState==1  || xmlHttp.readyState==2 || xmlHttp.readyState==3)
	 {
		 var msg="<center><img src='images/loading.gif'></center>";
		 document.getElementById("feeed").innerHTML=msg;
	 }
}
function FirstPe(int)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Your browser do not support HTTP Request")
		 return
	 }
//	 alert(int);
	var url="sec.php"
	url=url+"?feend="+int
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=FiChangeden
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function FiChangeden()
{
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {
		 document.getElementById("feend").innerHTML=xmlHttp.responseText;
	 }
	 if (xmlHttp.readyState==0 || xmlHttp.readyState==1  || xmlHttp.readyState==2 || xmlHttp.readyState==3)
	 {
		 var msg="<center><img src='images/loading.gif'></center>";
		 document.getElementById("feend").innerHTML=msg;
	 }
}
function add_url()
{
	var txt = "<br><input type=\"text\" name=\"url[]\" size=50>";
	document.getElementById("dvUrl").innerHTML += txt;
}

//------------------------------------------------



function Inint_AJAX()
{
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
   try { return new XMLHttpRequest();          } catch(e) {} //Native Javascript
   alert("XMLHttpRequest not supported");
   return null;
}
function sendlet() {
     var req = Inint_AJAX();
     req.onreadystatechange = function ()
     {
          if (req.readyState==4 || req.readyState=="complete")
		  {
               if (req.status==200)
			   {
                    document.getElementById('sendd').innerHTML=req.responseText; //retuen value
               }
          }/*
		if (req.readyState!=4)
 		{
//			 var msg="Loading ...";
			 document.getElementById('adv').innerHTML="Waiting....";
 		}*/
     }
     req.open("GET", "sec.php?send=1&sid="+Math.random()); //make connection
     req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=windows-1256"); // set Header
     req.send(null); //send value
}




//-------------------------------------------------

/*
function SendNews(int)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Your browser do not support HTTP Request")
		 return
	 }
//	 alert(int);
	var url="sec.php"
	url=url+"?send="+int
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=sendChangeden
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function sendChangeden()
{
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {
		 document.getElementById("sendd").innerHTML=xmlHttp.responseText;
	 }
	 if (xmlHttp.readyState==0 || xmlHttp.readyState==1  || xmlHttp.readyState==2 || xmlHttp.readyState==3)
	 {
		 var msg="<center><img src='images/loading.gif'></center>";
		 document.getElementById("send").innerHTML=msg;
	 }
}
*/
/*
function SendNews(int)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Your browser do not support HTTP Request")
		 return
	 }
	var url="sec.php"
	url=url+"?send="+int
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=sendChange
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function sendChange()
{
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {
		 document.getElementById("sendd").innerHTML=xmlHttp.responseText;
	 }
	 if (xmlHttp.readyState==0 || xmlHttp.readyState==1  || xmlHttp.readyState==2 || xmlHttp.readyState==3)
	 {
		 var msg="<center><img src='images/loading.gif'></center>";
//		 document.getElementById("sendd").innerHTML=msg;
	 }
}
*/
