// JavaScript Document

var acc_sp=6;
var currentid=1;
var slidetimer;
var motiontimer;

function startupdate(id,action,total,noingroup){
	 clearTimeout(slidetimer);
	 clearTimeout(motiontimer);
	if(action=="prev"){
			if(currentid>4){
				  currentid=currentid-4;
			//	  document.getElementById('butprev').style.opacity=1;
			  } else {
			//	  document.getElementById('butprev').style.opacity=0.2;
			  }
	} else {
		if(currentid<=(total-(total%4))){
		  currentid=currentid+4;
			//	  document.getElementById('butnext').style.opacity=1;
		  } else {
			//	  document.getElementById('butnext').style.opacity=0.2;
//		  currentid=1;
		  }
	}
	if(document.getElementById("d"+currentid)!=null){
  		updatepos(id);
 	}
//	slidetimer=setTimeout("startupdate('container','next')",2000);
}

function updatepos(id){
  clearTimeout(motiontimer);
  var curpos=parseInt(document.getElementById(id).style.left);
  var fpos=-(document.getElementById("d"+currentid).offsetLeft);
  var accpos=(fpos-curpos)/acc_sp;
  document.getElementById(id).style.left=(curpos+accpos)+"px";
  motiontimer=setTimeout("updatepos('"+id+"')",1)
}



//floating tagbar //////////////////////////////////////////////
var IE=document.all?true:false;
if (!IE){
	window.captureEvents(Event.MOUSEMOVE);
} 
document.onmousemove=updatebox;
function updatebox(event) {
	if(document.getElementById('tagbar')!=null){
	var divc=document.getElementById('tagbar')
	if(IE){
		if(document.body.scrollWidth-(window.event.x+20)>divc.scrollWidth){
               divc.style.left=window.event.x+20;
			   		} else {
			divc.style.left=window.event.x-divc.scrollWidth-20;
				}
		if(document.documentElement.clientHeight-window.event.clientY>divc.scrollHeight){
               divc.style.top=window.event.y+20;
			   		} else {
			divc.style.top=window.event.y-divc.scrollHeight-20;
				}
			   } else {
		if(document.body.scrollWidth-(event.pageX+20)>divc.scrollWidth){
               divc.style.left=event.pageX+20+'px';
			   		} else {
			divc.style.left=event.pageX-divc.scrollWidth-20+'px';
				}
		if(document.documentElement.clientHeight-(event.pageY-window.pageYOffset)>divc.scrollHeight){
               divc.style.top=event.pageY+20+'px';
			   		} else {
			divc.style.top=event.pageY-divc.scrollHeight-20+'px';
				}
			   }
	}
}
 
//remark tagbox on mouse over/out ///////////////////////////////////////////////
function tagbartxt(displaystatus,tagtitle,width,style){

 document.getElementById('tagbar').style.display=displaystatus;
 document.getElementById('tagbar').style.width='inherit';
 if(style!=undefined){
	 document.getElementById('tagbar').style.backgroundColor='';
	 document.getElementById('tagbar').style.border='none';
 } else {
	 document.getElementById('tagbar').style.backgroundColor='#000000';
	 document.getElementById('tagbar').style.border='1px solid #333333';
 }
 if(tagtitle!=undefined){
	 document.getElementById('tagbar').innerHTML = tagtitle;	
 }
 
 if(width!=undefined){
	document.getElementById('tagbar').style.width=width+'px';
 }
}

//////////////////////////////////////////////////////////
//pop up 
function popup_page(url,w,h) {
	window.open(url,"_blank","width="+w+",height="+h+",resizable=yes,scrollbars=no,toolbar=no,top=100, left=100, menubar=no,screenX=0,screenY=0" )
}


function popup_file(url,width,height,title) {
 	html = "<html><head><title>"+title+"</title>" + "</head><body style='margin: 0px;'>" + "<IMG src='" + url + "' BORDER=0>" + "</body></html>";
	msgWindow=window.open('','msgWIn','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+width+',height='+height);
	msgWindow.document.write(html);
	msgWindow.opener = self;
	msgWindow.focus();
}

///////////////////////////////////////////////////////////
//for gallery
function gallerydetails(gno,gtotal,gtitle,gdes){
//	alert(gno+","+gtotal+","+gtitle+","+gdes);
	if(gtitle=="" && gdes==""){
		document.getElementById('gdetails').style.display='none';
	} else {
		document.getElementById('gdetails').style.display='block';
	}
	if(gtitle==""){
		document.getElementById('gtitle').style.display='none';
	}
	document.getElementById('gpageno').innerHTML="Photo - "+gno+"/"+gtotal;
	document.getElementById('gtitle').innerHTML=gtitle;
	document.getElementById('gdes').innerHTML=gdes;
}




//////////////////////////////////////////////////////////////////
//for contact 
function chkconform(){
var frm = document.frmSend;

if (frm.Name.value == ""){
 alert("Please Enter Your Name");
 frm.Name.focus();
 return false;
}

if (frm.Email.value == ""){
 alert("Please Enter Your Email");
 frm.Email.focus();
 return false;
}
if (frm.Subject.value == ""){
 alert("Please select a Subject");
 frm.Subject.focus();
 return false;
}
if (frm.Message.value == ""){
 alert("Please Enter Your Message");
 frm.Message.focus();
 return false;
}

if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(frm.Email.value))) {
  alert("Your Email is invalid. Please Enter Again");
  frm.Email.focus();
    //error = 1;
  return false;
}

if (checkChar(frm.Telephone.value)){
  alert("Your Telephone Number is invaild");
  frm.Telephone.focus();
  return false;
}

if (checkChar(frm.Fax.value)){
  alert("Your Fax Number is invaild");
  frm.Fax.focus();
  return false;
}

frm.Country.value = getCountry(frm.countrySelect.value)
frm.action.value = "addform";
frm.submit();

}

function checkChar(value){
var havechar = false;
 if(value!='')
   for (x=0;x<value.length;x++) {
   if (/^[a-zA-Z]$/.test(value.charAt(x)) )  
    {
      if(arguments.length>1)
        if(arguments[1]) {
         arguments[1].focus();
         arguments[1].value='';
        }
     havechar = true;
     //alert('');
     break;
    }
 }
return havechar; 
}
//


/////////////////////////////////////////////////////////////////////
//object display
function obj_display(obj,display){
	var obj_id=document.getElementById(obj);
	if(display==1){
		obj_id.style.display='block';
	} else {
		obj_id.style.display='none';
	}
}
