//+++-----------------------------------------------------------------+++\\

var sBrowser='';
	sBrowser = (navigator.appName.indexOf("Netscape") >= 0) ?  "NS" : 
	(navigator.appName.indexOf("Microsoft") >= 0) ?    "IE" : "OTHER";   
//+++-----------------------------------------------------------------+++\\
if(sBrowser=="IE"){
	var cls='className';
	document.write('<link href="style.css" rel="stylesheet" type="text/css">');
}else{
	document.write('<link href="style1.css" rel="stylesheet" type="text/css">');
	var cls='class';	
}


function getSel(){
	var txt = '';
	var foundIn = '';
	if (window.getSelection){
		txt = window.getSelection();
		foundIn = 'window.getSelection()';
	}else if(document.getSelection){
		txt = document.getSelection();
		foundIn = 'document.getSelection()';
	}else if (document.selection){
		txt = document.selection.createRange().text;
		foundIn = 'document.selection.createRange()';
	}else return;
	alert('Found in: ' + foundIn + '\n' + txt);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function addlist(action,field){

   if(action=="list"){
		var x=prompt("Please enter number of bullets","2");
		var y=prompt("Please enter color of bullet, Option Blue, Cyan , Grey","grey");
		y=y.toLowerCase();
		if(y=='blue')
			y="bluestxt";
		else if(y=='grey')
			y="txtgrey";
		else if(y=='cyan')
			y="txtcyan";
			myValue="<ul>";
			
		for(i=0;i<x;i++){
			myValue+="<li class="+y+"> <Insert text here> </li>\r\n"
		}
		
		myValue+="</ul>";
		insertAtCursor(field, myValue)
   }
   
	// insertAtCursor(document.frm.pagetxt, value);
	document.selection.empty();
}

//--------------- to remove whitespaces from both side of string, use following function ---\\
function trimAll(sString){
	while (sString.substring(0,1) == ' '){
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' '){
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
//------------------------------------------------------------------------------------------\\
//--------------- show haide divs Email -----------------------------------------------------------\\
// use following prefixes :'div' for <div> 'td' for column and 'sp' for span with same second element for all
//  e.g : div1,td1,sp1 
// function will be called wlike shDiv(1);
function shDiv(ID) //show hide div
{
	var divID='div'+ID;
	var spanID='sp'+ID;
	var tdID='td'+ID;
	if(document.getElementById(divID)) //if div exists
	if(document.getElementById(divID).style.display=='none'){ 
		document.getElementById(divID).style.display='inline'; 
		if(document.getElementById(tdID)) // if column exists
			document.getElementById(tdID).title='Click to collapse'; 
		if(document.getElementById(spanID)) // if span exists
			document.getElementById(spanID).innerHTML='(Collapse)';
		}else{ 
			document.getElementById(divID).style.display='none'; 
			if(document.getElementById(tdID))
				document.getElementById(tdID).title='Click to expand'; 
			if(document.getElementById(spanID))
				document.getElementById(spanID).innerHTML='(Expand)';
		}
}

function Ordfrm(val) //show hide div
 {	
 	//alert(val);
	//return false;
if(val==1){ //if div exists
		if(document.getElementById('divOrd1').style.display=='none'){
	    document.getElementById('divOrd1').style.display='block';
		document.getElementById('divOrd2').style.display='none';	   
		} else if(document.getElementById('divOrd1').style.display=='block'){
		document.getElementById('divOrd1').style.display='none';	
		
	}
 } else if (val==0){
	 if(document.getElementById('divOrd2').style.display=='none'){
	    document.getElementById('divOrd2').style.display='block';
		document.getElementById('divOrd1').style.display='none';	   
		} else if(document.getElementById('divOrd2').style.display=='block'){
		document.getElementById('divOrd2').style.display='none';
	 
    }
  }
}


function valForm(){
		
	var testimonials_title = trimAll(document.getElementById('testimonials_title').value);
	var my_name = trimAll(document.getElementById('testimonials_name').value);		
	var my_emailaddress = trimAll(document.getElementById('testimonials_email').value);
	var my_comments = trimAll(document.getElementById('html_text').value);
	
	if(testimonials_title == ''){
		
		alert('Please enter subject for testimonial');
		document.getElementById('testimonials_title').focus();		
		return false;
	}else if(my_name == ''){
		
		alert('Please enter your full name');
		document.getElementById('testimonials_name').focus();		
		return false;
	} else if(my_emailaddress == ''){
		
		alert('Please enter your email address');
		document.getElementById('testimonials_email').focus();		
		return false;		
	} else if(my_emailaddress != '' && !isValidEmail(my_emailaddress)){
		
		alert('Please enter valid email address, eg xyz@abc.com');
		document.getElementById('testimonials_email').focus();			
		return false;			
	} else if(my_comments =='' ){		
		alert('Please enter testimonial description');
		document.getElementById('html_text').focus();		
		return false;		
	
	} else{
		document.customer_testimonial.submit();
		return true;
	}
	////////////////////////////////////////////////	

 } 
 
 function valContactForm(){
		
	var my_name = trimAll(document.getElementById('name').value);		
	var my_emailaddress = trimAll(document.getElementById('email').value);
	var my_phone = trimAll(document.getElementById('phone').value);
	var security_code = trimAll(document.getElementById('security_code').value);	
	
	if(my_name == ''){
		
		alert('Please enter your full name');
		document.getElementById('name').focus();		
		return false;
	} else if(my_emailaddress == ''){
		
		alert('Please enter your email address');
		document.getElementById('email').focus();		
		return false;		
	} else if(my_emailaddress != '' && !isValidEmail(my_emailaddress)){
		
		alert('Please enter valid email address, eg xyz@abc.com');
		document.getElementById('email').focus();			
		return false;
		
	} else if(my_phone =='' ){		
		alert('Please enter contact no:');
		document.getElementById('phone').focus();		
		return false;
		
	} else if(security_code =='' ){		
		alert('Please enter the security code given below:');
		document.getElementById('security_code').focus();		
		return false;		
	
	} else{
		document.contact_us.submit();
		return true;
	}
	////////////////////////////////////////////////	

 }
 
  function productForm(){
		
	var cat_id = trimAll(document.getElementById('categories_id').value);		
	var products_name = trimAll(document.getElementById('products_name').value);
	var products_price = trimAll(document.getElementById('products_price').value);
	var pdf_file = trimAll(document.getElementById('pdf_file').value);	
	var doc_file = trimAll(document.getElementById('doc_file').value);	
	
	if(cat_id == ''){
		
		alert('Please select product category');
		document.getElementById('categories_id').focus();		
		return false;
	} else if(products_name == ''){
		
		alert('Please enter product name');
		document.getElementById('products_name').focus();		
		return false;		
	} else if(products_price == ''){
		
		alert('Please enter product price');
		document.getElementById('products_price').focus();			
		return false;
		
	} else if(pdf_file =='' ){		
		alert('Please upload product PDF file');
		document.getElementById('pdf_file').focus();		
		return false;
		
	} else if(doc_file =='' ){		
		alert('Please upload product DOC file');
		document.getElementById('doc_file').focus();		
		return false;		
	
	} else{
		document.productform.submit();
		return true;
	}
	////////////////////////////////////////////////	

 }
 
 function productForm2(){
		
	var cat_id = trimAll(document.getElementById('categories_id').value);		
	var products_name = trimAll(document.getElementById('products_name').value);
	var products_price = trimAll(document.getElementById('products_price').value);
	//var pdf_file = trimAll(document.getElementById('pdf_file').value);	
	//var doc_file = trimAll(document.getElementById('doc_file').value);	
	
	if(cat_id == ''){
		
		alert('Please select product category');
		document.getElementById('categories_id').focus();		
		return false;
	} else if(products_name == ''){
		
		alert('Please enter product name');
		document.getElementById('products_name').focus();		
		return false;		
	} else if(products_price == ''){
		
		alert('Please enter product price');
		document.getElementById('products_price').focus();			
		return false;
		
	} 
	/*else if(pdf_file =='' ){		
		alert('Please upload product PDF file');
		document.getElementById('pdf_file').focus();		
		return false;
		
	} else if(doc_file =='' ){		
		alert('Please upload product DOC file');
		document.getElementById('doc_file').focus();		
		return false;		
	
	}*/ else{
		document.productform.submit();
		return true;
	}
	////////////////////////////////////////////////	

 }
 
 function validateFields()
{
	var comment_my_name=document.myform.comment_my_name.value;
	if(comment_my_name==""){
		alert("Please enter the comment title!");
		document.myform.comment_my_name.focus();
		return false;
	}
	var comment_my_email=document.myform.comment_my_email.value;
	if(comment_my_email==""){
		alert("Please enter your email!");
		document.myform.comment_my_email.focus();
		return false;
	}
	if(comment_my_email!="")
	{
		AtPos = comment_my_email.indexOf("@")
		StopPos = comment_my_email.lastIndexOf(".")
		if (AtPos == -1 || StopPos == -1) 
		{
		alert("Not a valid email address!");
		document.myform.comment_my_email.focus();
		return false;
		}
	}
	var verification_code=document.myform.verification_code.value;
	if(verification_code==""){
		alert("Please enter the verification code!");
		document.myform.verification_code.focus();
		return false;
	}
	
return true;
}
 
 function domainForm(theFrm){
	 
	var domain_name = trimAll(theFrm.domain_name.value);		
	
	if(domain_name ==''){		
		alert('Please enter the domain name in the following format:\n\n  domainname.com');
		theFrm.domain_name.focus();		
		return false;		
	} else {		
		return true;
	}	
 }
 
  function blogForm(theFrm){
	 
	var blog_post_title = trimAll(theFrm.blog_post_title.value);
	var blog_category_id = trimAll(theFrm.blog_category_id.value);
	var contents = trimAll(theFrm.contents.value);
	
	if(blog_post_title =='') {
		
		alert('Please enter the blog title');
		theFrm.blog_post_title.focus();		
		return false;		
		
	} else if(blog_category_id == ''){		
		
		alert('Please select blog category');
		theFrm.blog_category_id.focus();		
		return false;
		
	/*} else if(contents == ''){		
		
		alert('Please enter some blog description');
		theFrm.contents.focus();		
		return false;		*/
		
	} else {		
		return true;
	}	
 }
 
 function valSearchForm(theFrm){
	
	//alert(theFrm.keywords.value);
	
	var keyword = trimAll(theFrm.keywords.value);		
	var pricefrom = trimAll(theFrm.pfrom.value);
	var priceto = trimAll(theFrm.pto.value);
	//var security_code = trimAll(document.getElementById('security_code').value);	
	
	if((keyword =='') && (pricefrom=='') && (priceto=='')){		
		alert('Please make the following corrections:\n\n * At least one of the fields in the search form must be entered.');		
		return false;		
	} else {		
		return true;
	}	
 }

function shDiv2(divID) // show hide div
{
	if(document.getElementById(divID).style.display=='none'){
		document.getElementById(divID).style.display='inline';
	}else{
		document.getElementById(divID).style.display='none';	
	}	
}

 
//------------------------------------------------------------------------------------------\\
// call follwing function on keypress event of a field and that field will
// accept only numeric values and '.' IE only: now it works in mozilla too
//function validatePrice()
//{
	//if ( ( (event.keyCode < 48) && (event.keyCode != 46) ) || (event.keyCode > 57)) 
		//event.returnValue = false;
//}
function validatePrice(e){
	if(sBrowser=='IE'){
		if ( ( (e.keyCode < 48) && (e.keyCode != 46) ) || (e.keyCode > 57)) 
			return false;	
	}else{
		if ( ( (e.charCode < 48) && (e.charCode != 46) && (e.charCode != 0)) || (e.charCode > 57) ) 
			return false;	   						
   }
}

function compareDates (value1, value2) {
   var date1, date2;
   var month1, month2;
   var year1, year2;

   month1 = value1.substring (0, value1.indexOf ("-"));
   date1 = value1.substring (value1.indexOf ("-")+1, value1.lastIndexOf ("-"));
   year1 = value1.substring (value1.lastIndexOf ("-")+1, value1.length);

   month2 = value2.substring (0, value2.indexOf ("-"));
   date2 = value2.substring (value2.indexOf ("-")+1, value2.lastIndexOf ("-"));
   year2 = value2.substring (value2.lastIndexOf ("-")+1, value2.length);

   if (year1 > year2) return 1;
   else if (year1 < year2) return -1;
   else if (month1 > month2) return 1;
   else if (month1 < month2) return -1;
   else if (date1 > date2) return 1;
   else if (date1 < date2) return -1;
   else return 0;
}
  
  
var http_request = false;
function makePOSTRequest(url, parameters) {
      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('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
  
}
  
function confirmdel(message,url){
	if(confirm(message)){
		document.location.href=url;
	}
}

function noSpaces(e){
	if(sBrowser=='IE'){
		if (e.keyCode == 32) return false;	
   }else{
		if (e.charCode == 32) return false;	   						
   }
}

function charOnly(e){
	if(sBrowser=='IE'){
		
		if ((e.keyCode <65 || e.keyCode>90) && (e.keyCode <97 || e.keyCode>122)  ) return false;	
   }else{
		
		if ((e.charCode <65 || e.charCode>90) && (e.charCode <97 || e.charCode>122) ) return false;	   						
   }
}

function charNumeric(e)
{
 if(sBrowser=='IE')	
   {
		if ((e.keyCode <65 || e.keyCode>90) && (e.keyCode <97 || e.keyCode>122) && (e.keyCode <48 || e.keyCode>57))
			return false;	
   }
   else
   {
		if ((e.charCode <65 || e.charCode>90) && (e.charCode <97 || e.charCode>122) && (e.charCode <48|| e.charCode>57))
			return false;	   						
   }
}
// worlks just like php in_array
function in_array(needle, haystack) {
     for (var i = 0; i < haystack.length; i++) {
         if (haystack[i] == needle) {
             return  true;
        }
    }
     return  false;

}
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function changeimg(divname,imgname,oimg,simg)
{

	if(divname.style.display=='inline')
       imgname.src=simg;
	else
	  imgname.src=oimg;
	
}
