/*Rotating Testimonails*/
var uniqueArr = new Array();
var y;

function testimonials(classname,showtotal,arrayName){
	if(showtotal > arrayName.length)
		showtotal = arrayName.length;
	
	for(var i=0; i < showtotal; i ++){
		y = Math.ceil(Math.random()*arrayName.length);
		uniqueArr[i] = arrayName[y-1];
		arrayName.splice(y-1,1);
	}
	
	for(var i = 0; i < showtotal; i++){
		document.write("<div class=\"" + classname + "\">");
		document.write(uniqueArr[i]);
		document.write("</div>");
	};
}

/*Tabs*/
function closeTab(){
	for(var i=0; i < 5; i++){
		var topTab = "tab"+i;
		var topTabInfo = "tabinfo"+i;
		var topTabObject = document.getElementById(topTab);
		var topTabInfoObject = document.getElementById(topTabInfo);
		
		if (topTabObject && topTabInfoObject){
			topTabObject.className = "";
			topTabInfoObject.style.display = "none";
		}
	}
}

function throwContent(tabnum){
		closeTab();
	
		var topTab = "tab"+tabnum;
		var topTabInfo = "tabinfo"+tabnum;
		var topActiveTabObject = document.getElementById(topTab);
		var topTabInfoObject = document.getElementById(topTabInfo);
		
		if(topActiveTabObject && topTabInfoObject){
			topActiveTabObject.className = "active";
			topTabInfoObject.style.display = "block";
		}
}

function makeWin(imsrc, ww, wh) {
	ww=ww+25; wh=wh+50;
	w1=window.open('','w1','width='+ww+',height='+wh+',status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
	w1.document.open();
	w1.document.write("<html><head><title>Image Zoom<\/title><META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\"><META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\"><\/head>");
	w1.document.write("<body bgcolor='#FFFFFF' text='#000000' leftmargin=2 topmargin=10><p align=center>");
	w1.document.write("<img name=theimg src=" + imsrc + "><br>");
	w1.document.write("<a href=\"javascript:window.close();\"><font size=1 face=tahoma color=#000000>close window<\/font><\/a><\/body><\/html>");
	w1.document.focus();
};

function ShippingPopUp(url,h){
	var ShippingWin=0;
	if(ShippingWin){
			if(!ShippingWin.closed) ShippingWin.close();
		}
	ShippingWin = open(url,'popup2','scrollbars=yes, left=0, top=0, width=700, height=455');
	ShippingWin.focus();
}

function ShowPoem(w, h){
	var ShowPoemWin=0;
	var width=w, height=h;
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	if(ShowPoemWin){
			if(!ShowPoemWin.closed) ShowPoemWin.close();
		}
	ShowPoemWin = open('showpoem.html','popup',styleStr);
	ShowPoemWin.focus();
}

function PopUp(url,h,w){
	var popUpWin=0;
	if(popUpWin){
			if(!popUpWin.closed) popUpWin.close();
		}
	popUpWin = open(url,'popup2','resizable=yes, left=0, top=0, scrollbars=yes, width=' + w + ', height=' + h);
	popUpWin.focus();
}

function openWindow(url) {
	popupWin = window.open(url, 'openWin', "width=400, height=250, scrollbars=yes, resizable=yes");
}

function isEmail(str) {
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
    var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
    var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
    return (!r1.test(str) && r2.test(str));
}

function checkForm() {
	if(document.optin.OILB_EMAIL) document.optin.OILB_EMAIL.value=trim(document.optin.OILB_EMAIL.value); 
	if(document.optin.OILB_FIRSTNAME) document.optin.OILB_FIRSTNAME.value=trim(document.optin.OILB_FIRSTNAME.value); 
	if(document.optin.OILB_LASTNAME) document.optin.OILB_LASTNAME.value=trim(document.optin.OILB_LASTNAME.value);
 if(isEmail(document.optin.OILB_EMAIL.value) == "") {
   alert("Your e-mail address seems not to be valid.");
   document.optin.OILB_EMAIL.focus();
   return false;
 }
 /*if(document.optin.OILB_FIRSTNAME.value == "") {
   alert("You must provide a value for First Name.");
   document.optin.OILB_FIRSTNAME.focus();
   return false;
 }
   if(document.optin.OILB_LASTNAME.value == "") {
   alert("You must provide a value for Last Name.");
   document.optin.OILB_LASTNAME.focus();
   return false;
 } */
}

function trim(value) {
 startpos=0;
 while((value.charAt(startpos)==" ")&&(startpos<value.length)) {
   startpos++;
 }
 if(startpos==value.length) {
   value="";
 }
 else {
   value=value.substring(startpos,value.length);
   endpos=(value.length)-1;
   while(value.charAt(endpos)==" ") {
     endpos--;
   }
   value=value.substring(0,endpos+1);
 }
 return(value);
}

function openWin(wName, wWidth, wHeight, wResize)
{
features = 'top=0,left=0,scrollbars=1,status=0,resizable=' + ((wResize) ? 0 : 0) + ((wWidth) ? ',width=' + wWidth : '') + ((wHeight) ? ',height=' + wHeight : '');
popWin = window.open('', wName, features);
if(popWin.focus) { popWin.focus(); }
return true;
}

function validateProductForm () {
	var form_to_validate = document.orderform;
	var select_tags = document.getElementsByTagName('select');
	var all_selected = 'true';
	for (i=0; i < select_tags.length; i++) {
		if ((select_tags[i].value == '') || (select_tags[i].value == 'Please Select'))
			all_selected = 'false';
	}

	if (all_selected == 'false') {
		alert ('Please choose your option');
		return false;
	} else
		return true;
}




