function frmChecked(val,args) {
	args.IsValid =  jQuery("#"+val.controltovalidate).is(':checked');
}



function zoomin(){
if(parent.parent.document.body.style.zoom!=0)
parent.parent.document.body.style.zoom*=1.2;
else
parent.parent.document.body.style.zoom=1.2;
}

function zoomout(){
if(parent.parent.document.body.style.zoom!=0)
parent.parent.document.body.style.zoom*=0.833;
else
window.parent.document.body.style.zoom=0.833;
}






/*------------------------------ Login and SignUp pop up --------------------------------------------------*/
function ShowPassword()
{
	document.getElementById('ForgotDiv').style.display='block'; 
	document.getElementById('ForgotUserNameDiv').style.display = 'none';
	document.getElementById('rfvUserNameReqiest').style.display = 'none';
	document.getElementById('PasswordSent').style.display = 'none';
	document.getElementById('btnPassword').className = "PasswordActive";
	document.getElementById('btnUserName').className = "btnNormal";	
}
function ShowUserName()
{
	document.getElementById('ForgotUserNameDiv').style.display = 'block'; 
	document.getElementById('ForgotDiv').style.display='none';
	document.getElementById('txtForgotEmail').value = '';
	document.getElementById('rfvForgotEmail').style.display = 'none';
	document.getElementById('UserNameSent').style.display = 'none';
	document.getElementById('btnUserName').className = "UserNameActive";
	document.getElementById('btnPassword').className = "btnNormal";
	
}
function HidePassword()
{
	document.getElementById('ForgotDiv').style.display = 'none';
	document.getElementById('btnPassword').className = "btnNormal";
}
function HideUserName()
{
	document.getElementById('ForgotUserNameDiv').style.display = 'none'; 
	document.getElementById('btnUserName').className = "btnNormal";
}
function CancelEverything()
{
	document.getElementById('LoginPopup').style.display='none';
	document.getElementById('fade').style.display='none';
	document.getElementById('LoginButton'). className = "LoginButton";
	document.getElementById('txt_usernamelogin').value = '';
	document.getElementById('txt_passwordlogin').value = '';
}

function doClick(buttonName,e,textboxid) 
{
	var characterCode;
	if (e && e.which)
	{
		e = e;
		characterCode = e.which;
	}
	else
	{
		characterCode = e.keyCode;
	}
	if (characterCode == 13)
	{
		
		var btn = document.getElementById(buttonName);
		if (btn != null) 
		{
			btn.click();
			if(window.event)
				window.event.keyCode = 0;
		}
		return false;
	}
	else if (characterCode == 27)
	{
		//alert('working');
		document.getElementById(textboxid).value = '';
	}
	else
	{
		return true;
	}
}

function ShowLogIn() 
{

	document.getElementById('LoginPopup').style.display='block';
	document.getElementById('fade').style.display='block';
	//document.getElementById('LoginButton').className = "LoginBackgroundAlt";
}

/*---------------------------------------------------------------------------------------------*/

function verticalRotator(name,parentid,listHeight,detailHeight,timercount,pausecount,currentClass,rotateClass,slideSpeed)
{
	this.name = name;
	this.initialized = false;
	this.currentIndex = 0;
	this.slideSpeed = slideSpeed;
	this.listItems = new Array();
	this.detailItems = new Array();
	this.currentClass = currentClass;
	this.rotateClass=rotateClass;
	this.timer = false;
	this.timercount = timercount;
	this.pausecount = pausecount;
	this.parent = $('#'+parentid);
	this.listHeight=listHeight;
	this.detailHeight=detailHeight;
	this.load = function(startIndex,listName,divName)
	{
		var i = startIndex;
		var x = document.getElementById(listName+i);
		var y = document.getElementById(divName+i);
		while (typeof x!='undefined'&&x!=null && typeof y!='undefined' && y!=null)
		{
			this.listItems.push($(x));
			this.detailItems.push($(y));
			i++;
			x = document.getElementById(listName+i);
			y = document.getElementById(divName+i);
		}
		
		this.init();
	}
	this.init = function()
	{
		if (this.count()>0)
		{
			this.parent.css('height',this.count()*this.listHeight+this.detailHeight);
			this.detail(0);
		}
		else
		{
			this.parent.css('height',0);			
		}
		this.initialized=true;
		this.start();
	}
	this.start = function()
	{
		this.play(this.timercount);
	}
	this.play = function(duration)
	{
		this.pause();
		this.timer=setTimeout(this.name+'.rotate();',duration);
	}
	this.delay = function()
	{
		this.play(this.pausecount);
	}
	this.pause = function()
	{
		if (this.timer)
			clearTimeout(this.timer);
	}
	this.rotate = function()
	{
		if (this.currentIndex+1<this.count())
			this.detail(this.currentIndex+1);
		else
			this.detail(0);
		this.start();
	}
	this.detail = function(index)
	{
		if (index<this.count()&&index>=0)
		{
			if (index!=0)
			{
				this.listItems[index].addClass(this.rotateClass);
			}
			if (this.initialized)
			{
				this.listItems[this.currentIndex].removeClass(this.currentClass);
				this.listItems[this.currentIndex].removeClass(this.rotateClass);
			}
			for (var i=0;i<this.count();i++)
			{
				if (i!=index)
					this.detailItems[i].slideUp(this.slideSpeed);
			}
			if (index==0)
			{
				this.listItems[index].addClass(this.rotateClass);
			}
			if (this.initialized)
				this.detailItems[index].slideDown(this.slideSpeed,eval('function callback() {'+this.name+'.listItems[index].addClass('+this.name+'.currentClass)}'));
			this.currentIndex=index;
		}
		return false;
	}
	this.count = function()
	{
		return this.listItems.length;
	}
}

/* ROTATOR RANDOM */
function tabBlock(name,startTab,count,timercount,pausecount,autoplay)
{
	/*
		name:	the defined name of the variable within javascript, eg: var x = new tabBlock('x'...)
		startTab: the tab to show by default, -1 = random or zero, if random count is required to be the total count. Cannot use random when the total count is unknown
		count: see startTab.
		timercount: when using automatic rotation, the length of time for normal view duration (in milliseconds)
		pausecount: when using automatic rotation, the length of time for a delayed view duration (in milliseconds)
		autoplay: when true starts the automatic rotation
	*/
	this.name = name;
	this.playing = false;
	this.tabs = new Array();
	this.pages = new Array();
	this.currentIndex = startTab;
	this.running = false;
	this.timer = false;
	if (typeof timercount == 'undefined' || timercount==null)
		this.timercount = 5000;
	else
		this.timercount = timercount;
	if (typeof pausecount == 'undefined' || pausecount==null)
		this.pausecount = 15000;
	else
		this.pausecount = pausecount;
	if (typeof autoplay == 'undefined' || autoplay==null)
		this.autoplay=false;
	else
		this.autoplay=autoplay;
	if (typeof this.currentIndex != 'undefined')
	{
		if (this.currentIndex < 0 && typeof count != 'undefined' && count != null && count > 0)
		{	
			this.currentIndex = ( Math.floor( Math.random() * count ) + 1 ) ;
		}
	}
	else
		this.currentIndex = 1;
	
	
	
	this.count = function()
	{
		return this.pages.length;
	}
	this.add=function(id,tabobjectid)
	{
		this.pages.push($('#'+id));
		this.tabs['T'+this.pages.length]=$('#'+tabobjectid);
		if (this.pages.length==this.currentIndex)
			this.show(this.currentIndex);
		else		
			this.hide(this.pages.length-1);
	}
	this.hide=function(index)
	{
		this.pages[index].css('display','none');
	}
	this.play = function(duration)
	{
		this.running=true;
		this.playing=true;
		this.pause();
		this.timer=setTimeout(this.name+'.rotate();',duration);
	}
	this.toggle = function()
	{
		if (this.playing==true)
		{		
			this.playing=false;
			this.pause();
		}
		else
			this.play(0);
	}
	this.pause = function()
	{
		if (this.timer)
			clearTimeout(this.timer);
	}
	this.delay = function()
	{
		this.play(this.pausecount);
	}	
	this.rotate = function()
	{
		if (this.currentIndex+1<=this.count())
			this.detail(this.currentIndex+1);
		else
			this.detail(1);
		this.start();
	}	
	this.start = function()
	{
		this.play(this.timercount);
	}
	this.detail=function(index)
	{
		this.currentIndex=index;
		for(var i=0;i<this.pages.length;i++)
		{
			if (i==index-1)
			{
				this.pages[i].css('display','block');
				if (typeof this.tabs['T'+(i+1)]!='undefined' && this.tabs['T'+(i+1)]!=null)
					this.tabs['T'+(i+1)].addClass('active');
			}
			else
			{
				this.hide(i);
				if (typeof this.tabs['T'+(i+1)]!='undefined' && this.tabs['T'+(i+1)]!=null)
					this.tabs['T'+(i+1)].removeClass('active');
			}
		}
	}
	this.show=function(index)
	{
		if (this.running)
			this.delay();
		this.detail(index);
	}
	if (this.autoplay==true)
		this.play(this.timercount);
}

// PRINTING FUNCTIONALITY FOR ARTICLES
var srcvalue = '';
var counter = 0;
var timer;
function printcontent(panename) {
	if (panename==null||panename=='')
	panename = 'ContentPane'
	myRef = window.open('/print.aspx','mywin','left=20,top=20,width=700,height=700,toolbar=1,resizable=1,scrollbars=yes');
	srcvalue = document.getElementById('dnn_' + panename).innerHTML;
	counter = 10;
	waitfortarget();
}

function waitfortarget() {
	counter--;
	if (!myRef.document.getElementById('dnn_ContentPane'))
	{
	//DO NOTHING
		if (counter > 0) {
			timer=setTimeout("waitfortarget()", 1500);
		}
		else {
			alert('Unable to load article. Please try again later.');
		}
	}
	else {
	donetarget();
	}
}
function donetarget() {
	myRef.document.getElementById('dnn_ContentPane').innerHTML = srcvalue;
	myRef.print();
}

// Design Center Functionality
function designCenterChangeStory(linkID, storyID, divID,targetID) {
	var dtObj = document.getElementById(divID).getElementsByTagName('dt');
	var ddObj = document.getElementById(divID).getElementsByTagName('dd');

	document.getElementById(targetID).innerHTML = document.getElementById(storyID).innerHTML;
	for(var i = 0; i< dtObj.length; i++){
	        var aObj =  dtObj[i].getElementsByTagName('a');
                for(var k = 0; k < aObj.length; k++){
                         if(aObj[k].id == linkID){
                            $('#'+linkID).addClass('current');
                         }
                         else{
                            $('#'+aObj[k].id).removeClass('current');
                         }
                }
        }

}

// SHOW HIDE FULL ARTICLE
//$().ready( function() {
//  showShortArticle();
//});

function showShortArticle() {
  $("div.article p:gt(2)").each( function(i, item) { 

	var strCollapsed = "<div id='expandCollapseArea'><div class='expandCollapse'><div class='option'>Turn OFF Collapse / Expand Article</div>";
	strCollapsed += "<a href='#' class='button' onclick='showFullArticle(); return false;'>Read Full Article</a><div class='clear'></div></div></div>";

	$(item).slideUp();
	$("div#expandCollapseArea").replaceWith(strCollapsed);
  });
}

function showFullArticle() {
  $("div.article p").each( function(i, item) { 

	var strExpanded = "<div id='expandCollapseArea'><div class='pagination'><a href='#' class='disabled'>&laquo; Prev</a> Page <a href='#' class='active'>1</a>";
	strExpanded += " | <a href='#'>2</a> | <a href='#'>3</a> <a href='#' class='enabled'>Next &raquo;</a></div><div class='expandCollapse'><div class='option'>Turn OFF Collapse / Expand Article</div>";
	strExpanded += "<a href='#' class='buttonUp' onclick='showShortArticle(); return false;'>Collapse Article</a><div class='clear'></div></div></div>";


	$(item).slideDown();
	$("div#expandCollapseArea").replaceWith(strExpanded);
  });
}

// CROSS SITE SEARCH FUNCTIONALITY
function ProductSearch( input, url ) {	
	if ( input != "" ) { 
		window.open( url, '', 'width=700,height=600,resizable=yes,scrollbars=yes,toolbar=yes,location=yes,status=yes,menubar=yes' ); 
    } 
    else {
		alert ( "Please enter a text string to search for." );
	} 
} 

function ratings(rateing_id,rating_class){
 document.getElementById('rate').className="rating "+rating_class+"star";
 var value = '';
 switch (rating_class){
 case "one":
 value=1;
 break;
 case "two":
 value=2;
 break;
 case "three":
 value=3;
 break;
 case "four":
 value=4;
 break;
 case "five":
  value=5;
 break;
 }
 document.getElementById('rateIt').value=value;
 document.getElementById('comment').focus();
}