//Current Date
var months = new Array('Януари','Февруари','Март','Април','Май','Юни','Юли','Август','Септември','Октомври','Ноември','Декември')
function writeDate(){
	var now = new Date();
	top.headerFrame.document.getElementById('date_cell').innerHTML = now.getDate()+" "+months[now.getMonth()]+" "+now.getFullYear();
	//document.write(now.getDate()+" "+months[now.getMonth()]+" "+now.getFullYear());
}

//Product Categories
var productCategories = new Array('access','animalid','comment','controllers','telexes','voice');

//sets menuFrame & rightFrame to be empty
function setEmptyFrames(){
	if (top.menuFrame.location.href.indexOf("left_menu_empty.htm") == -1) {
		top.menuFrame.location =  "left_menu_empty.htm";//"products/left_menu.htm"; up too
	}
	if (top.rightFrame.location.href.indexOf("right_menu_empty.htm") == -1) {
		top.rightFrame.location =  "right_menu_empty.htm";
	}
}

//sets all frames to be prepared for frames
function setProductsFrames(){
	if (top.centerFrame.location.href.indexOf("home.htm") == -1) {
		top.centerFrame.location =  "home.htm";//"products/products.htm";
	}
	if (top.rightFrame.location.href.indexOf("right_menu_empty.htm") == -1) {
		top.rightFrame.location =  "right_menu_empty.htm";
	}
}

//toggles menu items visibility on/off (executed: onClick and onLoad)
function menuCategoryClick(categoryName)
{
	//alert("menuCategoryClick() executed with:\ncategoryName: "+categoryName+"\nURL: "+location.href);
	//collapses all menu categories
	for (var cat_id = 0; cat_id < productCategories.length; cat_id++) {
		document.getElementById(productCategories[cat_id]).style.display = 'none';
	}
	//if no category to expand - look for it in URL params 
	if (categoryName.length == 0) {
		if (location.href.indexOf("?")  != -1) {
    		categoryName = location.href.substring(location.href.indexOf("?")+1);
		}
	}
	//expand only selected category
	if (categoryName.length > 0) {
		//unfolds only selected category (that is not commentary - fix for only one item in this category!!!
		if (document.getElementById(categoryName) != null &&
			categoryName != 'comment' && categoryName != 'animalid') {
			document.getElementById(categoryName).style.display = 'block';
		}	
		//set rightFrame to category products
		var rightMenuPath = categoryName+"/right_menu_"+categoryName+".htm";
		if (top.rightFrame.location.href.indexOf(rightMenuPath) == -1) {
			top.rightFrame.location = rightMenuPath;
		}	
	}
}

function menuCategoryClick_fromCenterFrame(categoryName)
{
	//load left menu and expand apropriate category (passed as URL param)
	/* //always load page, no IF!
	if (top.menuFrame.location.href.indexOf("products/left_menu.htm") == -1) { 
		top.menuFrame.location =  "products/left_menu.htm?"+categoryName;//"products/left_menu.htm"; up too
	}
	*/
	top.menuFrame.location = "products/left_menu.htm?"+categoryName;
	//the rest is useless - menuCategoryClick() handles URL params
	/*
	//collapses all menu categories
	for (var cat_id = 0; cat_id < productCategories.length; cat_id++) {
		top.menuFrame.document.getElementById(productCategories[cat_id]).style.display = 'none';
	}
	if (categoryName.length > 0) {
		//unfolds only selected category (that is not comment - fix for only one item in this category!!!
		if (top.menuFrame.document.getElementById(categoryName) != null &&
			categoryName != 'comment') {
			//document.getElementById(categoryName).style.display = 'block';
			top.menuFrame.document.getElementById(categoryName).style.display = 'block';
		}	
		//set rightFrame to category products
		var rightMenuPath = "products/"+categoryName+"/right_menu_"+categoryName+".htm";
		if (top.rightFrame.location.href.indexOf(rightMenuPath) == -1) {
			top.rightFrame.location = rightMenuPath;
		}	
	}
	*/
}

//imageWindowPopup
function openImageWindow(img, width, height) {
		winId = window.open('', 'ImageWindow', 'width=' + (width+20) + ',height=' + (height+20));
		winId.document.write('<body><center>');//onLoad="if (window.focus) window.focus()"
		winId.document.write('<a href="javascript:window.close()">');// onClick="self.Close; return false;">');
		winId.document.write('<img src="' + img + 
							 	'" width="'+ width +
								'" height="'+ height +
								'" alt="Click to close window." border="0">');
		winId.document.write('</a></center></body>');
		winId.document.close();
}

function setTextAccordingToResolution() {
	//var res = 800;
	if (screen.width <= 800) {
		//alert("Resizing!");
		var smallSize = "11px";//"0.9em";
		top.headerFrame.document.getElementById('pasURL_cell').style.fontSize = smallSize;
		//top.headerFrame.document.getElementById('pasURL_cell').className = "HeaderButtons_small";
		top.headerFrame.document.getElementById('date_cell').style.fontSize = smallSize;
	}
}


