function ChkAllNone(obj,id){
	var tbs = document.getElementById('imagesH').getElementsByTagName('INPUT');
	for (var zxc0 = 0;zxc0<tbs.length;zxc0++)
	{
		if(!tbs[zxc0].disabled){
		tbs[zxc0].checked = obj.checked;
		}
	}
}
function getSingleImage(obj,width,height,isItForDownload,helpText){
	if(typeof(popupWindow) == "object")
		{
			window.popupWindow.hide();
		}
		if(document.getElementById("hidSearchPage")){
			document.getElementById("hidSearchPage").value='';
		}
	popupWindow=dhtmlwindow.open("lbBox", "iframe", textLangArray[0]+obj.name+"&popup=1", '', "width="+width+"px,height="+height+"px,resize=0,scrolling=0,center=1", "recal",helpText)
	
	popupWindow.onclose=function(){ 
	// ajax function call written in checkuname.js to unset the session when pop up window is closed
	unsetSession(); 
	if(isItForDownload == 1){
//		window.parent.location.href = window.parent.location.href;
	}	
		return true;
	}
}


function addSelectedToLightbox(chkboxName,width,height,helpText)
{
	//alert('amita');
	var url = '';
	if(typeof(popupWindow) == "object")
		{
			window.popupWindow.hide();
		}
	if(chkboxName != ''){	
		url = getSelectedImages(chkboxName);
	}
	else{
		url = document.getElementById("hidSearchPage").value;
	}
	if(url == ''){
		return false;
	}	
	else{
		document.getElementById("hidSearchPage").value = url;	
	}	
	var functionUrl = textLangArray[0]+"index.php?page=verify_lightbox_middle";
	var	windowTitle = "";		
	popupWindow=dhtmlwindow.open("myWinBox", "iframe", functionUrl, windowTitle,"width="+width+"px,height="+height+"px,resize=0,scrolling=0,center=1","recal",helpText);
	popupWindow.onclose=function(){ 
		// ajax function call written in checkuname.js to unset the session when pop up window is closed
		unsetSession(); 
			return true;
		}		
}

function changeImageTitle(idd,title_tmp){
	if(document.getElementById('isPreview').checked){
		document.getElementById(idd).title='';
	}else{
		document.getElementById(idd).title=title_tmp;
	}		
		
}

function goPage(e,element_id){	
	if(document.getElementById(element_id)){
	var url = "";
	var pagesize = search_options[1];
	var offset = '';
	var start = '';
	var end = '';
	var lastpage = search_options[2];
	var temp = '';
	var linktoshow = "5";
	var currentPage = document.getElementById(element_id).value;
	var event_action = false;

	if(window.event){				//For IE
		keycode = window.event.keyCode;
	}else{							// For Mozilla
		keycode = e.which;
	}
	if(keycode == 13){
		event_action = true;
	}
	
	if(parseInt(currentPage) > parseInt(lastpage)){
		currentPage = lastpage;
	}
	//var total = "{/literal}{$totalimg}{literal}";
	//var order_by = "{/literal}{$smarty.request.order_by}{literal}";
	offset = (currentPage - 1) * pagesize;
	
	if((!currentPage.match(/[0-9]/)) || (currentPage.match(/[a-zA-Z]/)) || parseInt(currentPage)<1) 
	{
		//document.getElementById('go_page').className = "tb-border";
        document.getElementById(element_id).focus();
        isTextBoxFocused=true;
		return true;
	}else if(e.type == "click"){
		event_action = true;
	}
	if(event_action == true){
		//document.getElementById('go_page').className = "";
		if(parseInt(currentPage)%linktoshow == 0)
		{
			temp = parseInt(currentPage / linktoshow) -1;
		}
		else
		{
			temp = parseInt(currentPage / linktoshow);
		}	
		start = temp * parseInt(linktoshow);
		end = start + parseInt(linktoshow);
		tmp_location = search_options[0];
		if(tmp_location.match(/offset=[0-9]+/g)){
			tmp_location = tmp_location.replace(/offset=[0-9]+/g,"offset="+offset);		
			tmp_location = tmp_location.replace(/(currentpage=[0-9]+)/g,'currentpage='+currentPage);
			tmp_location = tmp_location.replace(/(start=[0-9]+)/g,'start='+start);
			tmp_location = tmp_location.replace(/(end=[0-9]+)/g,'end='+end);
		}else{
			tmp_location = tmp_location + "&offset=" + offset + "&currentpage=" + currentPage + "&start=" + start + "&end=" + end;
		}		
		window.location.href = tmp_location;
		return false;
	}
	}	
	return true;
}
