﻿var cornerSize = '5px';	
function getTabHeader(id){
    return $('#tab'+id);
}

function getTabContent(id){
    return $('#tabContent'+id);
}

function switchTab(id,activate){
    elem = getTabHeader(id);
    elemContent =  getTabContent(id);
    if (activate){               
        elem.addClass('active');
	    elemContent.removeClass('hidden');
    }else{
        elem.removeClass('active');
        elemContent.addClass('hidden');
    }
}

function activateTab(id)
{
    switchTab(activeTabId,false);
    switchTab(id,true);
    activeTabId = id;
}

function SlideElement(active,next){
    this.$active = active;
    this.$next = next;
}

function changeSlide($active, $next)
{
    $active.fadeOut("slow", function(){$active.removeClass('active'); $next.fadeIn("slow"); $next.addClass('active'); if (!isIE()){$next.corner(cornerSize);} });
}

function initFancyBox(){     
         $("a.fancyLink").fancybox({
	        'titlePosition'	: 'over'
	    });	 
}

function initCorners()
{    
    var postText = "";
    $( "div.cornered" ).not("#menu, #subMenu").each( function() 
        {
             $( this ).corner(cornerSize);
        } 
    );
    
    if (!isIE())
    {    
        $( "#menu, #subMenu" ).each( function() 
        {
             $( this ).corner(cornerSize);
        } 
    );
        $( "img.cornered" ).each( function() 
            {
                 $( this ).corner(cornerSize);
            } 
        );
    }
}

function isIE(){
    return $.browser.msie;
}

function fancyHelper() {
    /*$("div.hideMovie")[0].style.display = 'block';*/
}

function switchTextBox(container, elem, activate) {   
    elem = $(elem); 
    if (activate){
        elem.addClass('activeTextBox');
        elem.removeClass('inactiveTextBox');
    }else{
        elem.removeClass('activeTextBox');
        elem.addClass('inactiveTextBox');
    }
}

function nextNewsPage()
{
  $.ajax({
          type: "POST",
          url: "controls/News.ascx/LoadNextPage",
          data: "{}",
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function(data) {
            alert(data);
            // Do something interesting here.
          },
          error: function(xmlRequest, errorType, exception) 
          {
            alert(xmlRequest);
            alert(errorType);
            alert(exception);
          }
    });
}

function updatePanelEndRequest (sender, args) {
    initFancyBox();
}

$(function() {
            $(this).bind("contextmenu", function(e) {
                e.preventDefault();
            });
        });

function disableSelection(target){
    if (typeof target.onselectstart!="undefined") //IE route
	    target.onselectstart=function(){return false}
    else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
	    target.style.MozUserSelect="none";
    else //All other route (ie: Opera)
	    target.onmousedown=function(){return false}
    target.style.cursor = "default"
}


function setSelectedMenuItem(){
    var subpageID = $('#hdnSubpageID').val();    
    var $elem = $('#menu ul.m_horiz li a[href*='+subpageID+']').parent().parent().parent().parent().addClass('menuSelected');

    var $elem = $('#menu ul.m_horiz li.mainMenu a[href*=' + subpageID + ']').parent();
    
    if ($elem){ 
        $elem.addClass('menuSelected');
    }
} 

function initEnquiry(){    
    $('td.enquiryText input:text').each(function(key, val) { $(val).addClass('inactiveTextBox'); });
    $('td.enquiryText textarea').each(function(key, val) { $(val).addClass('inactiveTextBox'); });
}
