function OpenContent(ContentID, Type){
   var Content = new String(ContentID);
   var reg = 'http[s]?://\w[\.\w]+';
   
   if ( Type == undefined )
		Type = 0;
   switch (parseInt(Type)){
		case 0: //Normal
				//Si no tiene contenido
				if ( trim(Content) == '' )
						return;   
				//Si es una direccion externa		
				if ( Content.indexOf('http://',0)  >= 0 ){
						window.open(Content)
				}else {
						//Si es un content ID
						reg = '^[0-9]+';
						if (Content.search(reg) >= 0) 
							{
								document.all.ifrmContent.src = 'Public/Content/Content.aspx?QnContentID='+Content+ GetLanguage() ;
							}
							else{ //Si es una direccion interna
							if ( CheckWord(Content.substring(Content.lastIndexOf('.')+1,Content.length))){
									window.open(UrlRootPath + Content)
									}else{
										if (Content.indexOf('?')>0)
											document.all.ifrmContent.src = Content+ '&QnContentID=0' + GetLanguage();		
										else
											document.all.ifrmContent.src = Content+ '?QnContentID=0' + GetLanguage();		
										}	
							}
						}

				break;	
		case 1: //Category
				OpenCategory(ContentID);
				break;	
		case 2: //Category Detail
				OpenCategoryDetail(ContentID);
				break;	
		case 3: //Product
				OpenProduct(ContentID);
				break;	
   }
   
}

function OpenCategory(CategoryID){
	document.all.ifrmContent.src = 'Public/Content/Category.aspx?QnParentID='+CategoryID;
}

function OpenCategoryDetail(CategoryID){
	document.all.ifrmContent.src = 'Public/Content/CategoryDetail.aspx?QnCategoryID='+CategoryID;
}

function OpenProduct(ProductID){
	document.all.ifrmContent.src = 'Public/Content/Product.aspx?QnProductID='+ProductID;
}

function CheckWord(word){
   var extensions = new Array('pdf','doc','xsl');
   var i;
	for ( i=0; i<extensions.length;i++){
		if ( extensions[i] == word )	
			return true;
	}
return false;
}


function IfrmRezise(){
    var ScreenWidth;
   var RealWidth;
    document.all("ifrmContent").style.height='100%';
   if(document.getElementById && !(document.all)) {
		h = document.getElementById('ifrmContent').contentDocument.body.scrollHeight;
		document.getElementById('ifrmContent').style.height = h;
	}
	else if(document.all) {
	h = document.frames('ifrmContent').document.body.scrollHeight;
	document.all.ifrmContent.style.height = h;
	ScreenWidth = document.frames('ifrmContent').screen.width;
	RealWidth = ScreenWidth - ( ScreenWidth * 76 / 100 ) - 10;
	if ( document.all.ifrmContent.document.body.scrollWidth > RealWidth ){
				document.all.ifrmContent.scrolling = 'auto';
			}else document.all.ifrmContent.scrolling = 'no';
	}
	//alert(h)
}

function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = /  /g;
   while (temp.match(obj)) { temp = temp.replace(obj, " "); }
   return temp;
}

function SetPath(text){
	if ( text != '' )
		document.all.spnPath.innerHTML = text;
}

function GetLanguage(){
	var qstring = window.location.search.substring(1);
	var index = 0;
	var result;
	index = qstring.indexOf('lng');
	if ( index < 0){
		return '';
	}else {
		//siempre lng debe ser el ultimo parametro del querystring
		result = '&lng=' + qstring.substring(eval(index+4),eval(qstring.length-index+4));
		return result
	}
}

function RightClick(){
	if ( window.event.button == 2 ){
		alert('Derechos Reservados');
		return false;
	}
}

function refresh()
{
	window.top.document.all("btnRefresh").click()
}

