function search_sshape(){
	selIndex = document.getElementById('prodsearch').selectedIndex;
	selIndex2 = document.getElementById('modelsearch').selectedIndex;
	selIndex3 = document.getElementById('numbersearch').selectedIndex;
	selIndex4 = document.getElementById('sshape').selectedIndex;
	data = document.getElementById('prodsearch').options[selIndex].value;
	data2 = document.getElementById('modelsearch').options[selIndex2].value;
	data3 = document.getElementById('numbersearch').options[selIndex3].value;
	data4 = document.getElementById('sshape').options[selIndex4].value;
	window.location = 'index.php?prodsearch='+data+'&modelsearch='+data2+'&numbersearch='+data3+'&sshape='+data4+'&ssize=All-SS';
}

function search_bshape(){
	selIndex = document.getElementById('prodsearch').selectedIndex;
	selIndex2 = document.getElementById('modelsearch').selectedIndex;
	selIndex3 = document.getElementById('numbersearch').selectedIndex;
	selIndex4 = document.getElementById('bshape').selectedIndex;
	data = document.getElementById('prodsearch').options[selIndex].value;
	data2 = document.getElementById('modelsearch').options[selIndex2].value;
	data3 = document.getElementById('numbersearch').options[selIndex3].value;
	data4 = document.getElementById('bshape').options[selIndex4].value;
	window.location = 'index.php?prodsearch='+data+'&modelsearch='+data2+'&numbersearch='+data3+'&bshape='+data4+'&bsize=All-BS';
}

function search_size(){
	selIndex = document.getElementById('prodsearch').selectedIndex;
	selIndex2 = document.getElementById('modelsearch').selectedIndex;
	selIndex3 = document.getElementById('numbersearch').selectedIndex;
	selIndex4 = document.getElementById('size').selectedIndex;
	data = document.getElementById('prodsearch').options[selIndex].value;
	data2 = document.getElementById('modelsearch').options[selIndex2].value;
	data3 = document.getElementById('numbersearch').options[selIndex3].value;
	data4 = document.getElementById('size').options[selIndex4].value;
	window.location = 'index.php?prodsearch='+data+'&modelsearch='+data2+'&numbersearch='+data3+'&size='+data4;
	//alert(window.location.href);
	//alert(document.forms['product_search'].action);
    //document.forms['product_search'].submit();
}

function search_cat(){
	selIndex = document.getElementById('prodsearch').selectedIndex;
	data = document.getElementById('prodsearch').options[selIndex].value;
	window.location = 'index.php?prodsearch='+data+'&modelsearch=All-M&numbersearch=All-MN';
	//document.forms['product_search'].submit();
}

function gotolink(){
	selIndex = document.getElementById('prodsearch').selectedIndex;
	data = document.getElementById('prodsearch').options[selIndex].value;
	selIndex2 = document.getElementById('itemsizelink').selectedIndex;
	data2 = document.getElementById('itemsizelink').options[selIndex2].value;
	window.location = 'index.php?prodsearch='+data+'&modelsearch='+data2+'&numbersearch='+data2;
	//document.forms['product_search'].submit();
}

function search_1(type){
	selIndex = document.getElementById('prodsearch').selectedIndex;
	selIndex2 = document.getElementById('modelsearch').selectedIndex;
	selIndex3 = document.getElementById('numbersearch').selectedIndex;
	data = document.getElementById('prodsearch').options[selIndex].value;
	data2 = document.getElementById('modelsearch').options[selIndex2].value;
	data3 = document.getElementById('modelsearch').options[selIndex2].value;
	if (data2 == 'All-M') {
		data3 = 'All-MN';
	}
	if(type == 1){
		//urlocation = 'index.php?prodsearch='+data+'&modelsearch='+data2+'&numbersearch=All-MN&size=All-S&shape=All-SH';
		urlocation = 'index.php?prodsearch='+data+'&modelsearch='+data2+'&numbersearch='+data3;
	}else if(type == 2){
		//urlocation = 'index.php?prodsearch='+data+'&modelsearch='+data2+'&numbersearch=All-MN&bsize=All-BS&bshape=All-BSH';
		urlocation = 'index.php?prodsearch='+data+'&modelsearch='+data2+'&numbersearch='+data3;
	}else{
		//urlocation = 'index.php?prodsearch='+data+'&modelsearch='+data2+'&numbersearch=All-MN&size=All-S&shape=All-SH';
		urlocation = 'index.php?prodsearch='+data+'&modelsearch='+data2+'&numbersearch='+data3;
	}
	
	window.location = urlocation;
	//document.getElementById('preload-img').style.display="block";
	
	//window.location = 'index.php?prodsearch='+data+'&modelsearch='+data2+'&numbersearch=All-MN&size=All-S&shape=All-SH';
	//alert(window.location.href);
	//alert(document.forms['product_search'].action);
    //document.forms['product_search'].submit();
}

function search_2(type){
	selIndex = document.getElementById('prodsearch').selectedIndex;
	//selIndex2 = document.getElementById('modelsearch').selectedIndex;
	selIndex3 = document.getElementById('numbersearch').selectedIndex;
	data = document.getElementById('prodsearch').options[selIndex].value;
	data2 = document.getElementById('numbersearch').options[selIndex3].value;
	data3 = document.getElementById('numbersearch').options[selIndex3].value;
	if (data3 == 'All-MN') {
		data2 = 'All-M';
	}
	if(type == 1){
		//urlocation = 'index.php?prodsearch='+data+'&modelsearch=All-M&numbersearch='+data3+'&size=All-S&shape=All-SH';
		urlocation = 'index.php?prodsearch='+data+'&modelsearch='+data2+'&numbersearch='+data3;
	}else if(type == 2){
		//urlocation = 'index.php?prodsearch='+data+'&modelsearch=All-M&numbersearch='+data3+'&bsize=All-BS&&bshape=All-BSH';
		urlocation = 'index.php?prodsearch='+data+'&modelsearch='+data2+'&numbersearch='+data3;
	}else if(type == 6){
		//urlocation = 'index.php?prodsearch='+data+'&modelsearch=All-M&numbersearch='+data3;
		urlocation = 'index.php?prodsearch='+data+'&modelsearch='+data2+'&numbersearch='+data3;
	}else{
		//urlocation = 'index.php?prodsearch='+data+'&modelsearch=All-M&numbersearch='+data3+'&size=All-S&shape=All-SH';
		urlocation = 'index.php?prodsearch='+data+'&modelsearch='+data2+'&numbersearch='+data3;
	}
	window.location = urlocation;
	
	//alert(window.location.href);
	//alert(document.forms['product_search'].action);
    //document.forms['product_search'].submit();
}

function changeselect(obj,div1,div2,action,page,method){
	selIndex = obj.selectedIndex;
	data = obj.options[selIndex].value;
	ajax(div1,'index.php?page='+page,action+'&data='+data,div2,1);
	//ajax('mod_name','index.php?page=search','mod_n='+data,'mod_name_loader');
}

function SubmitSearch(obj,obj2,obj3,obj4,obj5,obj6,div1,div2,action,page,method){
	selIndex = document.getElementById(obj).selectedIndex;
	selIndex2 = document.getElementById(obj2).selectedIndex;
	selIndex3 = document.getElementById(obj3).selectedIndex;
	selIndex4 = document.getElementById(obj4).selectedIndex;
	selIndex5 = document.getElementById(obj5).selectedIndex;
	selIndex6 = document.getElementById(obj6).selectedIndex;
	data = document.getElementById(obj).options[selIndex].value;
	data2 = document.getElementById(obj2).options[selIndex2].value;
	data3 = document.getElementById(obj3).options[selIndex3].value;
	data4 = document.getElementById(obj4).options[selIndex4].value;
	data5 = document.getElementById(obj5).options[selIndex5].value;
	data6 = document.getElementById(obj6).options[selIndex6].value;
	ajax(div1,'index.php?page='+page,action+'&prod='+data+'&size='+data2+'&shape='+data3+'&material='+data4+'&person='+data5+'&types='+data6,div2,1);
}

//xconfirm
function xconfirm(value){
	var agree=confirm(value);
	if (agree)
		return true ;
	else
		return false ;
}

//hide show
function show(id){
	document.getElementById(id).style.display='block';
}

function hide(id){
	document.getElementById(id).style.display='none';
}

function clear(id){
	document.getElementById(id).innerHTML = '';
}


function fadeIn(id){
	setTimeout("show('"+id+"')",500)
	opacity(id, 0, 100, 500)
}

function fadeOut(id){
	setTimeout("hide('"+id+"')",500)
 	opacity(id, 100, 0, 500)
}

function fadejax(id,page,poststr){
	fx = xconfirm('Are your sure you want to Delete?');
	if (fx){
		fadeOut(id);
		ajax('clear',page,poststr);
		
	}
	return false ;
}

function fadejax2(id,id2,page,poststr){ 
	fx = xconfirm('Are your sure you want to Delete?');
 	if (fx){
		fadeOut(id2);
		fadeOut(id);
		ajax('clear',page,poststr);
	
	}
	return false ;
}

function fadeToggle(id){ 
	if(document.getElementById(id).style.display == 'none'){
		fadeIn(id);
	}else{
		fadeOut(id);
	}
}

function toggle(id){ 
	if(document.getElementById(id).style.display == 'none'){
		show(id);
	}else{
		hide(id);
	}
}

function highlight(field) {
  field.focus();
  field.select();
}

// Opacity

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}

// End Opacity

// my.js
function changeSubmit(frm,txt){
		document.forms[frm].Submit.value = txt;
}
