function switchTabs(tabnum) {
    if(tabnum == "1" || tabnum == "2" || tabnum == "3") {
	    input_tabs = document.getElementById("input_tabs");
	    input_tabs.value = tabnum;
        document.seach.submit();
    }
    return false;
}
function switchSort(sortorder) {
    if(sortorder == "1" || sortorder == "2" || sortorder == "3" || sortorder == "4") {
	    input_sort = document.getElementById("input_sort");
        if(input_sort.value == sortorder) {
            input_ascdesc = document.getElementById("input_ascdesc");
            if(input_ascdesc.value != "ASC") {
                input_ascdesc.value = "ASC";
            } else {
                input_ascdesc.value = "DESC";
            }
        }
	    input_sort.value = sortorder;
        document.seach.submit();
    }
    return false;
}

function sendto(mailuser, maildomain, mailtld, mailsubject) {
	if(!mailuser && !maildomain && !mailtld) {
		var mailuser = "contact";
		var maildomain = "ramitrade";
		var mailtld = "com";
	}
	if(!mailsubject) {
		document.location = "mailto:"+mailuser+"@"+maildomain+"."+mailtld+"";
	} else {
		mailsubject = escape(mailsubject);
		document.location = "mailto:"+mailuser+"@"+maildomain+"."+mailtld+"?subject="+mailsubject+"";
	}
}

function viewimage(pid, wid, hei) {
	var windowName = "popup";
	w = screen.availWidth;
	h = screen.availHeight;
	var popW = wid, popH = hei;
	var scrollB = 'no';
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	newWindowWin=window.open('image_show.php?id='+pid, windowName,'width=' + popW + ',height=' + popH + ',scrollbars=' + scrollB + ',screenX=' +leftPos +',screenY=' +topPos +',top=' +topPos +',left=' +leftPos);
}

function galleryGo(toimage, galleryimagesay, lrgimghrf, lrgw, lrgh) {
	document.getElementById("imgsplash" + galleryimagesay).src = eval('images' + galleryimagesay +'['+ toimage +']');
	eval('images' + galleryimagesay + '["activeimg"] = '+ toimage);
	document.getElementById("imglink" + galleryimagesay).href = "javascript:viewimage('"+lrgimghrf+"',"+lrgw+","+lrgh+");";
}

function galleryMove(galleryimagesay, imgmoveto) {
	var next = false;
	if (eval('images'+ galleryimagesay + '["activeimg"]') == null) {
    	eval('images'+ galleryimagesay + '["activeimg"] = '+ 0);
	}
	var len = eval('images'+ galleryimagesay + '.length');
	for (var i = 0 ; i < len ; i++) {
		if(imgmoveto == 'next') {
			if((len - 1) == eval('images'+ galleryimagesay + '["activeimg"]')){
				document.getElementById("imgsplash" + galleryimagesay).src = eval('images'+ galleryimagesay +'['+ i +']');
				
				lrgw = eval('widths'+ galleryimagesay +'['+ i +']');
				lrgh = eval('heights'+ galleryimagesay +'['+ i +']');
				lrgimghrf = eval('links'+ galleryimagesay +'['+ i +']');
				document.getElementById("imglink" + galleryimagesay).href = "javascript:viewimage('"+lrgimghrf+"',"+lrgw+","+lrgh+");";
				
				eval('images'+ galleryimagesay + '["activeimg"] = '+ 0);
				break;
			}
			if(next == true) {
				document.getElementById("imgsplash" + galleryimagesay).src = eval('images'+ galleryimagesay +'['+ i +']');
				
				lrgw = eval('widths'+ galleryimagesay +'['+ i +']');
				lrgh = eval('heights'+ galleryimagesay +'['+ i +']');
				lrgimghrf = eval('links'+ galleryimagesay +'['+ i +']');
				document.getElementById("imglink" + galleryimagesay).href = "javascript:viewimage('"+lrgimghrf+"',"+lrgw+","+lrgh+");";
				
				eval('images'+ galleryimagesay + '["activeimg"] = '+ i);
				next = false;
				break;
			}
			if(i == eval('images'+ galleryimagesay + '["activeimg"]')){
				next = true;
			}
		}
		if(imgmoveto == 'previous') {
			if(eval('images'+ galleryimagesay + '["activeimg"]') == 0){
				document.getElementById("imgsplash" + galleryimagesay).src = eval('images'+ galleryimagesay +'['+ (len - 1) +']');
				
				lrgw = eval('widths'+ galleryimagesay +'['+ i +']');
				lrgh = eval('heights'+ galleryimagesay +'['+ i +']');
				lrgimghrf = eval('links'+ galleryimagesay +'['+ i +']');
				document.getElementById("imglink" + galleryimagesay).href = "javascript:viewimage('"+lrgimghrf+"',"+lrgw+","+lrgh+");";
				
				eval('images'+ galleryimagesay + '["activeimg"] = ' + (len - 1));
				break;
			}
			if(i == eval('images'+ galleryimagesay + '["activeimg"]')){
				document.getElementById("imgsplash" + galleryimagesay).src = eval('images'+ galleryimagesay +'['+ (i - 1) +']');
				
				lrgw = eval('widths'+ galleryimagesay +'['+ i +']');
				lrgh = eval('heights'+ galleryimagesay +'['+ i +']');
				lrgimghrf = eval('links'+ galleryimagesay +'['+ i +']');
				document.getElementById("imglink" + galleryimagesay).href = "javascript:viewimage('"+lrgimghrf+"',"+lrgw+","+lrgh+");";
				
				eval('images'+ galleryimagesay + '["activeimg"] = '+ (i - 1));
				break;
			}
		}
	}
}