// JavaScript Document

function openPictureWindow(img,nm,picnm,w,h){
	openColorboxFile(img,w,h,nm);
	//return false;
}
function openTellFriendWindow(pg,nm,w,h,txt){
	openColorboxFile(pg,w,h,txt);
	//return false;
}
// Generic function to open a window
function openAWindow( pg, w, h, txt ) {
    openColorboxFile(pg,w,h,txt);
	//return false;
}
function openGenericWindow( pg, w, h, txt ){
	openColorboxFile(pg,w,h,txt);
	//return false;
}
function openCardWindow(pg,w,h){
	openColorboxCARD(pg,w,h,'Credit Card Payment Information');
	//return false;
}
function openAdminCardWindow(pg,w,h){
	openColorboxFile(pg,w,h,'Payment Method');
	//return false;
}
function submitRating(iid,ca){
	if( document.getElementById('ratingvote') ){
		var vote = document.getElementById('ratingvote').options[document.getElementById('ratingvote').selectedIndex].value;
		var url = "/log_rating.php?itemID=" + iid + "&CA=" + ca + "&vote=" + vote;
		openColorboxFile(url,350,150,'Rate Product');
	}
}

function openInfoWindow(pg,w,h,txt){
	openColorboxFile(pg,w,h,txt);
	//return false;
}

function refreshParent(url){
	return true;
	window.parent.location.href=url;
}

function autoSubmit(form)
{
	window.location.href = form.shipMethod.options[form.shipMethod.selectedIndex].value;
}

function openColorboxCARD(hr,w,h,t){
	if(!w){
		w = "75%";
	}
	if(!h){
		h = "75%";
	}
	$.fn.colorbox({
		href:hr,
		title:t,
		width:w,
		height:h,
		iframe:"true",
		opacity:0,
		onClose:function(){  }
	}); 
	return false;
}

function openColorboxFile(hr,w,h,t){
	if(!w){
		w = "75%";
	}
	if(!h){
		h = "75%";
	}
	$.fn.colorbox({href:hr,title:t,width:w,height:h,iframe:"true",opacity:0}); 
	return false;
}

function openColorboxHTML(ht,w,h,t){
	if(!w){
		w = "75%";
	}
	if(!h){
		h = "75%";
	}
	$.fn.colorbox({html:ht,title:t,width:w,height:h,opacity:0}); 
	return false;
}


button2 = new Image();
button2.src = "/images/submitSecureButton-clicked.gif";
var theForm;
var requestSubmitted = false;
function disableButton(btn,form,buttonType) {
	if (!requestSubmitted){
		if (buttonType != null) {
			var buttonName = buttonType;
			btn.src = buttonName.src; // image swap happens here
		}
		theForm = form;
		btn.disabled = true;
		requestSubmitted = true;
		setTimeout("submitIt()", 250);
	} else {
		return false;
	}
}
function submitIt() {
	theForm.submit();
	return false;
}

function goback()
{
	window.history.go(-1)
}

function goback2()
{
	window.history.go(-2)
}

function checkrequired(which,margin) {
var message = "";
message += "The form was not submitted due to the following error(s).<br>\n";
message += "The following required fields are empty:<br>\n";
var pass=true;
var comma = "";
if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if(!tempobj){
			continue;
		}
		if (tempobj.name.substring(0,8)=="required") {
			if (((tempobj.type=="text"||tempobj.type=="textarea"||tempobj.type=="password")&&
			tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
			tempobj.options[tempobj.selectedIndex].value=='')||(tempobj.type=="checkbox"&&
			!tempobj.checked)) {
				shortFieldName=tempobj.name.substring(8,30);
				message += "<br> &raquo; " + shortFieldName.replace(/_/g," ");
				pass=false;
				comma = ", ";
         			}
     		 }
   	}
}
//message += "</ol>\n";
if (!pass) {
	//alert(message);
	openColorboxHTML(message,500,250);
	return false;
}
else
	return true;
}

function autoPriceFilterSubmit(form) {
		window.location.href = form.pfilter.options[form.pfilter.selectedIndex].value;
}

function autoMfgFilterSubmit(form) {
		window.location.href = form.mfgfilter.options[form.mfgfilter.selectedIndex].value;
}
  
function detectingFLASH() {
  var browser = navigator.userAgent.toLowerCase();
  flashVersion = 0;	
	// NS3+, Opera3+, IE5+ Mac
	if ( navigator.plugins != null && navigator.plugins.length > 0 ) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if ( typeof flashPlugin == 'object' ) { 
			if ( flashPlugin.description.indexOf('7.') != -1 ) flashVersion = 7;
			else if ( flashPlugin.description.indexOf('6.') != -1 ) flashVersion = 6;
			else if ( flashPlugin.description.indexOf('5.') != -1 ) flashVersion = 5;
			else if ( flashPlugin.description.indexOf('4.') != -1 ) flashVersion = 4;
			else if ( flashPlugin.description.indexOf('3.') != -1 ) flashVersion = 3;
		}
	} // IE4+ Win32 (VBscript)
	else if ( browser.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && browser.indexOf("win")!= -1 && browser.indexOf("16bit")== -1 ) {
	  document.write('<scr' + 'ipt language="VBScript"> n');
		document.write('on error resume next n');
		document.write('DIM obFlash n');
		document.write('SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.7") n');
		document.write('IF IsObject(obFlash) THEN n');
		document.write('flashVersion = 7 n');
		document.write('ELSE SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.6") END IF n');
		document.write('IF flashVersion < 7 and IsObject(obFlash) THEN n');
		document.write('flashVersion = 6 n');
		document.write('ELSE SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.5") END IF n');
		document.write('IF flashVersion < 6 and IsObject(obFlash) THEN n');
		document.write('flashVersion = 5 n');
		document.write('ELSE SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.4") END IF n');
		document.write('IF flashVersion < 5 and IsObject(obFlash) THEN n');
		document.write('flashVersion = 4 n');
		document.write('ELSE SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.3") END IF n');
		document.write('IF flashVersion < 4 and IsObject(obFlash) THEN n');
		document.write('flashVersion = 3 n');
		document.write('END IF');
	  document.write('</scr' + 'ipt> n');
  } // no Flash
  else {
	flashVersion = -1;
  }
return flashVersion;
}


function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

function displayValidationErrorMessage(msg,loc,remove){
	$('#' + loc + "_message").empty();
	$('#' + loc + "_message").append(msg);
	$('#' + loc).attr('style','display:block;');
	if(remove){
		setTimeout("hideToolMessage('" + loc + "')",4500);
	}
}
function hideValidationErrorMessage(loc){
	$('#' + loc + "_message").empty();
	$('#' + loc).attr('style','display:none;');
}

function doSearchThing(){
	$('#searchfield').val($('#searchfieldph').val());
	//document.write($('#searchfield').val());
	alert( $('#searchform').submit() );
}

function checkForumSearch(frm){  	
	document.getElementById('cxid').value = document.getElementById('search_where').options[document.getElementById('search_where').selectedIndex].value;  
}

(function() {
	var f = document.getElementById('searchbox_partner-pub-7993519228154114:8bu6v2-7eoi');
	if (!f) {
		f = document.getElementById('searchbox_demo');
	}
	if (f && f.q) {
		
		var q = f.q;
		var n = navigator;
		var l = location;
		if (n.platform == 'Win32') {
			q.style.cssText = 'border: 1px solid #7e9db9; padding: 2px;';
		}
		var b = function() {
			if (q.value == '') {
				q.style.background = '#FFFFFF url(http:\x2F\x2Fwww.google.com\x2Fcoop\x2Fintl\x2Fen\x2Fimages\x2Fgoogle_custom_search_watermark.gif) left no-repeat';
			}
		};
		var f = function() {
			q.style.background = '#ffffff';
		};
		q.onfocus = f;
		q.onblur = b;
		if (!/[&?]q=[^&]/.test(l.search)) {
			b();
		}
	}
})();



