﻿function setiFrame(objValue)
{
	document.getElementById("HotTypeFlag").value = objValue;
	document.getElementById("HotTypeInfo").submit();
	return true;
}

function SpecOrderOnSubmit() {
	var obj = document.getElementById('soemail');
	
	if(trim(obj.value) == "" || trim(obj.value)=="E-mail address..."){
		alert("Please enter an email address before subscription.");
		AlertInfoAdd("Please enter an email address before subscription.",0,0);
		obj.focus();
		obj.select();
		return false;
	}else if (!isEmail(obj.value)) {
		alert("Please enter a valid email address.");
		obj.focus();
		obj.select();
		return false;
	}
	return true;
}

function changeUrl(PageUrl, PageName, PageID)
{
	var PageSize = document.getElementById('PageSize').value;
	var Sortby	= document.getElementById('Sortby').value;
	location.href = PageUrl + "/" + PageName + "-"+PageSize+Sortby+PageID+"/";
}

function changePageSize(PageSize, PageUrl, PageName, PageID, SpecialTypeC)
{
	var Sortby	= document.getElementById('Sortby').value;
	if(SpecialTypeC != null && SpecialTypeC != "")
	{
		location.href = PageUrl + "/" + PageName + "-"+PageSize+Sortby+PageID+SpecialTypeC;
	}
	else
	{
		location.href = PageUrl + "/" + PageName + "-"+PageSize+Sortby+PageID+"/";
	}
}

function changeSortby(Sortby, PageUrl, PageName, PageID,SpecialTypeC)
{
	//var PageID = 1;
	var PageSize	= document.getElementById('PageSize').value;
	if(SpecialTypeC != null && SpecialTypeC != "")
	{
		location.href = PageUrl + "/" + PageName + "-"+PageSize+Sortby+PageID+ SpecialTypeC;
	}
	else
	{
		location.href = PageUrl + "/" + PageName + "-"+PageSize+Sortby+PageID+"/";
	}
}

function goPage(id, PageUrl, PageName)
{
	var PageSize = document.getElementById('PageSize').value;
	var Sortby	= document.getElementById('Sortby').value;
	location.href = PageUrl + "/" + PageName + "-"+PageSize+Sortby+id+"/";
}

function searchSubmit(){
	/*var subkeyword = $("SubKeyword").value;
	var minp = $("MinPrice").value;
	var maxp = $("MaxPrice").value;
	var pn = /^(-|\+)?\d+(\.\d+)?$/;
	if(trim(minp) == "" && trim(maxp) != ""){
		if(!pn.test(maxp)){						
			$("MaxPrice").value = "";
			$("MaxPrice").focus();
			return false;
		}else if(trim(maxp) < 0){												
			$("MaxPrice").value = "";
			$("MaxPrice").focus();
			return false;
		}
	}else if(trim(minp) != "" && trim(maxp) == ""){
		if(!pn.test(minp)){
			$("MinPrice").value = "";
			$("MinPrice").focus();
			return false;
		}
	}else if(trim(minp) != "" && trim(maxp) != ""){
		if(!pn.test(minp)){						
			$("MinPrice").value = "";
			$("MinPrice").focus();
			if(!pn.test(maxp)){						
				$("MaxPrice").value = "";
				$("MinPrice").focus();
				return false;
			}
			return false;
		}else if(trim(minp) < 0){
			if(!pn.test(maxp)){						
				$("MaxPrice").value = "";
				$("MaxPrice").focus();
				return false;
			}else if(trim(maxp) < 0){												
				$("MaxPrice").value = "";
				$("MaxPrice").focus();
				return false;
			}
		}
		if(!pn.test(maxp)){						
			$("MaxPrice").value = "";
			$("MaxPrice").focus();
			return false;
		}else if(trim(maxp) < 0){												
			$("MaxPrice").value = "";
			$("MaxPrice").focus();
			return false;
		}
	}
	if(minp != "" || maxp != "" || trim(subkeyword) != "" || $("videos").checked || $("discount").checked){
		dinoSearchEngne.saveViewSubmitCookie(minp,maxp,subkeyword,$("videos").checked,$("discount").checked);
		return true;
	}else{
		return false;	
	}*/
	var subkeyword    = jQuery("#SubKeyword").val();
	var objMinp       = jQuery("#MinPrice");
	var objMaxp       = jQuery("#MaxPrice");
	var minp          = objMinp.val();
	var maxp          = objMaxp.val(); 
	var pn            = /^(-|\+)?\d+(\.\d+)?$/;
	var flag 		  = false;
	if(trim(minp) == "" && trim(maxp) != ""){
		if(!pn.test(maxp)){						
			objMaxp.val("") ;
			objMaxp.focus();
			return false;
		}else if(trim(maxp) < 0){												
			objMaxp.val("") ;
			objMaxp.focus();
			return false;
		}
	}else if(trim(minp) != "" && trim(maxp) == ""){
		if(!pn.test(minp)){
			objMinp.val("") ;
			objMinp.focus();
			return false;
		}
	}else if(trim(minp) != "" && trim(maxp) != ""){
		if(!pn.test(minp)){						
			objMinp.val("") ;
			objMinp.focus();
			if(!pn.test(maxp)){						
				objMaxp.val("") ;
				objMinp.focus();
				return false;
			}
			return false;
		}else if(trim(minp) < 0){
			if(!pn.test(maxp)){						
				objMaxp.val("") ;
				objMaxp.focus();
				return false;
			}else if(trim(maxp) < 0){												
				objMaxp.val("") ;
				objMaxp.focus();
				return false;
			}
		}
		if(!pn.test(maxp)){						
			objMaxp.val("") ;
			objMaxp.focus();
			return false;
		}else if(trim(maxp) < 0){												
			objMaxp.val("") ;
			objMaxp.focus();
			return false;
		}
	}
	if(minp != "" || maxp != "" || trim(subkeyword) != "" 
		|| jQuery("#videos").attr("checked") == true 
		|| jQuery("#discount").attr("checked") == true){
		dinoSearchEngne.saveViewSubmitCookie(minp,maxp,subkeyword,jQuery("#videos").attr("checked"),jQuery("#discount").attr("checked"));
		return true;
	}else{
		return false;
	}
}

function getSortName(sortId){
	switch(parseInt(sortId)){
		case 1: return 'Price';
		case 4: return 'Release Date';
		case 5: return 'Popularity';
		case 6: return 'Reviews';
		case 7: return 'Diggs';
		case 8: return 'Videos';
	}
}
function setDiv(sourceDivID,targetDivID){
	document.getElementById(targetDivID).style.display="";
	document.getElementById(targetDivID).innerHTML = document.getElementById(sourceDivID).innerHTML;		
	document.getElementById(sourceDivID).innerHTML="";
}

var showProductid = 0;
var showdivp = 0;
function showWholesalePrice(pid){
	if(document.getElementById("tcbox_"+pid)){
		if(showProductid!=0){
			document.getElementById("tcbox_"+showProductid).style.display = "none";
		}
		showProductid = pid;
		document.getElementById("tcbox_"+showProductid).style.display = "";
		showdivp = 1;
	}
}
function moutWholesalePrice(){
	showdivp = 0;
	setTimeout(closeWholesalePrice, 250);
}
function mmoveWholesalePrice(){
	showdivp = 1;
}
function closeWholesalePrice(){
	if(showdivp==0 && showProductid!=0){
		document.getElementById("tcbox_"+showProductid).style.display = "none";
	}
}
