/*Validation for Contact us page*/

function validate1(frm) 
{ 
sname = frm.name; 
semail = frm.email; 
message = frm.comments; 
 
err_flag = 0; 
 
if (sname.value == "" || !removeSpaces(sname.value)) 
  { 
   alert ("Please enter proper Name!"); 
   sname.focus(); 
   sname.value=""; 
   return false;  
  } 
  else if (semail.value == "" || !validate_email(semail.value)) 
   { 
   alert ("Please enter proper Email!"); 
   semail.focus(); 
   return false;  
  } 
 
  else if (message.value == "" || !removeSpaces(message.value)) 
    { 
     alert ("Comment should not be blank!"); 
     message.focus(); 
     message.value=""; 
     return false; 
    }
 
} 

function validate2(frm) 
{ 
/*sothertunes = frm.othertunes;
sotherproduct = frm.otherproduct;
srecommendations = frm.recommendations;
sreason  = frm.reason;
ssuggestion  = frm.suggestion;
*/
semail = frm.email; 
 
err_flag = 0; 
 if (semail.value == "" || !validate_email(semail.value)) 
   { 
   alert ("Please enter proper Email!"); 
   semail.focus(); 
   return false;  
  } 
/*if (sothertunes.value == "" || !removeSpaces(sothertunes.value)) 
  { 
   alert ("Please put some comment on the first point!"); 
   sothertunes.focus(); 
   sothertunes.value=""; 
   return false;  
  } 
  else if ((frm.field1[0].checked == "") && (frm.field1[1].checked == "")) 
   { 
   alert("Please select an option on the 2nd point!");
   frm.field1[0].focus(); 
   return false;  
  } 
  else if (sotherproduct.value == "" || !removeSpaces(sotherproduct.value)) 
   { 
   alert ("Please put some comment on the 3rd point!"); 
   sotherproduct.focus();
   sotherproduct.value=""; 
   return false;  
  } 
 
  else if (srecommendations.value == "" || !removeSpaces(srecommendations.value)) 
    { 
     alert ("Please put some comment on the 4th point!"); 
     srecommendations.focus(); 
     srecommendations.value=""; 
     return false; 
    }
   	else if ((frm.field2[0].checked == "") && (frm.field2[1].checked == "")) 
    { 
	   alert("Please select an option on the 5th point!");
	   frm.field2[0].focus(); 
	   return false;  
  	} 
	 else if (sreason.value == "" || !removeSpaces(sreason.value)) 
    { 
		 alert ("Please put some comment on the 6th point!"); 
		 sreason.focus(); 
		 sreason.value=""; 
		 return false; 
    } 
	else if ((frm.field3[0].checked == "") && (frm.field3[1].checked == "")) 
   { 
	   alert("Please select an option on the 7th point!");
	   frm.field3[0].focus(); 
	   return false;  
   } 
	 else if (ssuggestion.value == "" || !removeSpaces(ssuggestion.value)) 
    { 
     alert ("Please put some comment on the 8th point!"); 
     ssuggestion.focus(); 
     ssuggestion.value=""; 
     return false; 
    } */
	
	 
} 
  
function validate_email(e) 
{ 
var str=e; 
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; 
 
if (!filter.test(str)) 
  return false; 
else 
  return true; 
} 
 
function removeSpaces(string) { 
var tstring = ""; 
string = '' + string; 
splitstring = string.split(" "); 
for(i = 0; i < splitstring.length; i++) 
tstring += splitstring[i]; 
return tstring; 
}

/*Bookmark Script*/

function bookmark()
{
	if (window.sidebar) // firefox
	{
		alert("mozila");
		window.sidebar.addPanel("Wirelesshut.com - " + document.title, window.location , "");
	}
	else if(window.opera && window.print)
	{ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',window.location);
		elem.setAttribute('title',document.title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)
	{// ie
	window.external.AddFavorite(window.location, 'Wirelesshut.com - ' + document.title);
	}else
	{
	alert("Sorry! Your browser doesn't support this function. Please press Ctrl+D to bookmark this site.");
	}
}
function book()
{
	alert("bookmark");
	if(document.all)
	{// ie
	alert("ie");
	window.external.AddFavorite(window.location, 'Wirelesshut.com - ' + document.title);
	}
	else if(window.sidebar) // firefox
	{
		alert("mozila");
		window.sidebar.addPanel("Wirelesshut.com - " + document.title, window.location , "");
	}	
	else if(window.opera && window.print)
	{ // opera
		alert("opera");
		var elem = document.createElement('a');
		elem.setAttribute('href',window.location);
		elem.setAttribute('title',document.title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else
	{
	alert("Sorry! Your browser doesn't support this function. Please press Ctrl+D to bookmark this site.");
	}
}


function AddBookmark(title,url) 
{ 
var ie=navigator.userAgent.toLowerCase();
var ua=navigator.userAgent.toLowerCase();
var isSafari=(ua.indexOf('webkit')!=-1);
var ie78=(ie.indexOf('msie 8')!=-1);
//alert(ie78)
if(ie78)
  {//alert("You need to press ctrl + D to bookmark our site.");
}
if(isSafari)
  {alert("You need to press ctrl + D to bookmark our site.");
}
if( document.all ) {
window.external.AddFavorite( url, title);
} else if( window.opera && window.print ) {
return true; 
}
else if (window.sidebar) { 
window.sidebar.addPanel(title, url,""); 
} 
}
