/* @Author : Robin Michael. 
	Date: 2011-08-21.
	Created For : Unique Computer Systems. 
*/

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

$(function() {
	
	//header search text
	$("#query").focus(function() {
		$("#query").val('');
	});
	$("#query").blur(function() {
		( $("#query").val() == '' ) ? $("#query").val('Search') : '';
	});
	
	$('#slides').slides({
		preload: true,
		preloadImage: 'images/loading.gif',
		play: 5000,
		hoverPause: false,
		generateNextPrev: false				
	});

	$('ul#portfolio').innerfade({
		speed: 1000,
		timeout: 3000,
		type: 'sequence'				
	});
	
	$('ul#portfolio2').innerfade({
		speed: 1000,
		timeout: 3300,
		type: 'sequence'										
	});
	
	$('ul#ul_testimonial').innerfade({
		speed: 'slow',
		timeout: 6000,
		type: 'sequence',
		containerheight: '1.5em'

	});


	$('.acc_trigger').click(function(){
		if( $(this).next().is(':hidden') ) { 
			$('.acc_trigger').removeClass('active').next().slideUp(); 
			$(this).toggleClass('active').next().slideDown(); 
		}
		else 
			$('.acc_trigger').removeClass('active').next().slideUp();
		
		return false; //Prevent the browser jump to the link anchor
	});
	$('.acc_container').hide();
	//$('.acc_trigger:first').addClass('active').next().show();

	$('.acc_trigger_casestudies').click(function(){
		if( $(this).next().is(':hidden') ) { 
			$('.acc_trigger_casestudies').removeClass('active').next().slideUp(); 
			$(this).toggleClass('active').next().slideDown(); 
		}
		else 
			$('.acc_trigger_casestudies').removeClass('active').next().slideUp();
		
		return false; //Prevent the browser jump to the link anchor
	});

	$('.productstab_container ').hide(); 

	$('.productstab').click(function(){
		if( $(this).next().is(':hidden') ) { 
			$('.productstab').removeClass('active').next().slideUp(); 
			$(this).toggleClass('active').next().slideToggle();
		}
		else 
			$('.productstab').removeClass('active').next().slideUp();
		
		return false; //Prevent the browser jump to the link anchor
	});

//set cookie for all anchor tag
	$("#pgBdy a").click( function() {
		var clkId = $(this).attr('id');
		if( clkId )
			$.cookie('yR78DsJetr56HG1cvbjJFDsPUsdA', clkId);
	});
	
// set cookie for left panel li

	$("[id^=lilftP_]").click( function() {
		var clkliId = $(this).attr('id');
		if( clkliId )
			$.cookie('zR78DsJetr56HG1cvbjJFDsPUsdB', clkliId);
	});
	
/* index.php starts here */
	
	$("#home_rm").click(function() { 
		var showTxt = $("#home_rm").text();
		( showTxt === 'Read more') ? $("#home_rm").text('Read less') : $("#home_rm").text('Read more');
		( $(this).parent().attr('class') === 'read') ? $(this).parent().attr('class', 'read1') : $(this).parent().attr('class', 'read');
		$("#home_desc").slideToggle(500);
	});
	
/* index.php ends here */
	
/* contactus.php starts here */
	$("#frmrequest").validate();	
/* contactus.php ends here */
	
});
