function getSubCategories(argCategoryCode) {
	document.getElementById("ifrmCrit").src="proxysubcategories.php?MASTERCATEGORYCODE="+argCategoryCode + "&RN=" + Math.floor(Math.random()*1000000)+ "&";
}

function getSubSubCategories(argSubCategoryCode) {
	document.getElementById("ifrmCrit").src="proxysubsubcategories.php?CATEGORYCODE="+argSubCategoryCode + "&RN=" + Math.floor(Math.random()*1000000)+ "&";
}

//gia tis ypokatigories
function iFrmCritCallback(doc) {
	var myData = doc.getElementById("CATEGORYCODE");
	document.getElementById("CATEGORYCODE").options.length = 0;
	for (var i=0; i < myData.options.length; i++) 	{
		var new_option = new Option(myData.options[i].text,myData.options[i].value);
		document.getElementById("CATEGORYCODE").options[i]=new_option;
	}
}

//gia tis ypo-ypokatigories
function iFrmCritCallback2(doc) {
	var myData = doc.getElementById("SUBCATEGORYCODE");
	document.getElementById("SUBCATEGORYCODE").options.length = 0;
	for (var i=0; i < myData.options.length; i++) 	{
		var new_option = new Option(myData.options[i].text,myData.options[i].value);
		document.getElementById("SUBCATEGORYCODE").options[i]=new_option;
	}
}

function IsNumeric(strString) {
   	var strValidChars = "0123456789";
   	var strChar;
   	var blnResult = true;
   	if (strString.length == 0) return false;
   //  test strString consists of valid characters listed above
   	for (i = 0; i < strString.length && blnResult == true; i++) {
	  strChar = strString.charAt(i);
	  if (strValidChars.indexOf(strChar) == -1) {
		 blnResult = false;
	  }
   	}
	return blnResult;
}

function navigateToPage(argDest,objPageToGo,argMaxPages) {
			if (IsNumeric(objPageToGo.value) == false) {
				objPageToGo.value = '';
				return;
			}
			if (objPageToGo.value <=0) {
				objPageToGo.value = '';
				return;
			}
			if (objPageToGo.value > argMaxPages) {
				objPageToGo.value = '';
				return;
			}
			var x;
			x = 'po.php' + argDest + 'PAGE='+objPageToGo.value+'&';
			window.location.href=x;
}

function changeNor(argDest,objNor) {
	var x;
	x = 'por.php' + argDest + 'NOR='+objNor.value+'&';
	window.location.href=x;
}

function PhotoPreview(argPhotoCode,argPos,argArr) {
	var nw = null;
	nw = window.open('lib/php/cpv.php?PHOTOCODE='+argPhotoCode+'&POS='+argPos+'&ARR='+argArr+'&','previewphotowin','width=700px,height=700px,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no,menubar=no');
	nw.focus(); 
}

function ArticlePreview(argSubjectCode) {
	var nw = null;
	nw = window.open('lib/php/cppp.php?ARTICLECODE='+argSubjectCode+'&','previewsubjectwin','toolbar=no,width=700px,height=700px');
}

//function addToPhotoBasket(argPhotoCode) {
//	document.getElementById("ifrmCrit").src="proxyPhotoBasket.php?ACTION=ADDITEM&PHOTOCODE="+argPhotoCode+"&RN=" + Math.floor(Math.random()*1000000)+ "&";
//}

function addToPhotoBasket(argPhotoCode,argTypeId,argPrice) {
	var s;
	var sPhotoIdPlusPhotoType;
	sPhotoIdPlusPhotoType = argPhotoCode+'_'+argTypeId;
	s = document.getElementById("ifrmCrit");
	s.src="proxyPhotoBasket.php?ACTION=ADDITEM&ITEMID="+sPhotoIdPlusPhotoType+"&PHOTOID="+argPhotoCode+"&ITEMTYPE="+argTypeId+"&ITEMPRICE="+argPrice+"&RN="+Math.floor(Math.random()*1000000)+"&";
	//alert(sPhotoIdPlusPhotoType);
	//window.close();
} 



function iFrmCritBasketCallback(doc,action,ditemid) {
	//alert(ditemid);
	var myData = doc.getElementById("photobasketitemscount"); 
	document.getElementById("PHOTOBASKETITEMSCOUNT").innerHTML = myData.innerHTML;
	if (action == "REMOVEITEM") {
		window.location.href="por.php?ACTION=PBASKETVIEW&QDEST=QDEST_PHOTOS&";
		//var Parent = document.getElementById('ttbl_'+ditemid);
		//while(Parent.hasChildNodes())
		//{
		//   Parent.removeChild(Parent.firstChild);
		//}
	}
}

function removeFromPhotoBasket(argPhotoCode,argTypeId) {
	var sPhotoIdPlusPhotoType;
	sPhotoIdPlusPhotoType = argPhotoCode+'_'+argTypeId;
	document.getElementById("ifrmCrit").src="proxyPhotoBasket.php?ACTION=REMOVEITEM&ITEMID="+sPhotoIdPlusPhotoType+"&DITEMID="+argPhotoCode+"&RN=" + Math.floor(Math.random()*1000000)+ "&";
}

function removeFromPhotoBasketNoRefresh(argPhotoCode,argTypeId) {
	var sPhotoIdPlusPhotoType;
	sPhotoIdPlusPhotoType = argPhotoCode+'_'+argTypeId;
	document.getElementById("ifrmCrit").src="proxyPhotoBasket.php?ACTION=REMOVEITEMNOREFRESH&ITEMID="+sPhotoIdPlusPhotoType+"&RN=" + Math.floor(Math.random()*1000000)+ "&";
}


function PhotoPreviewBasket(argPhotoCode,argPos,argArr) {
	var nw = null;
	nw = window.open('lib/php/cpb.php?PHOTOCODE='+argPhotoCode+'&POS='+argPos+'&ARR='+argArr+'&','previewphotowin','width=700px,height=700px,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no,menubar=no');
	nw.focus(); 
}