﻿dotoggle = true;

function editOverActions(box) {
    $(box).each(
	       function() {
	           $(this).mouseover(function() { $(this).addClass('box-over') }).mouseout(function() { $(this).removeClass('box-over') });
	           //$(this).mouseover(function() { $(this).find('.edit_text_link').show(); }).mouseout(function() { $(this).find('.edit_text_link').hide(); });
	       }
	    );
}

function cycle_pause(oid) {
    $('#object_content_' + oid).cycle('pause');
    $('#obj_' + oid + '_pause').hide();
    $('#obj_' + oid + '_play').show();
    return false
}

function cycle_play(oid) {
    $('#object_content_' + oid).cycle('resume');
    $('#obj_' + oid + '_play').hide();
    $('#obj_' + oid + '_pause').show();
    return false
}

function trimStr(str) {
    return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '').replace(/&nbsp;/g, '').replace(/[,]$/, '');
}

function chooseRandomCycle(oid, cycle_total) {
    var chosen_cycle = Math.floor(Math.random() * (cycle_total));
    $('#object_' + oid + ' .cycle_num_' + chosen_cycle).show();
}

function catPrintPage(id){
	window.open('/category_print.asp?cid='+id+'','print','width=600,height=500,scrollbars=1,resizable=1')
}

function valid_AdvSearch(){
	if(($('#fprice').val() != '') && ($('#tprice').val() != '')){
		if($('#tprice').val()*1 <= $('#fprice').val()*1){
			tempPrice = $('#tprice').val();
			$('#tprice').val($('#fprice').val());
			$('#fprice').val(tempPrice);
		}
	}
	$('#frm_advanced_search').submit();
}

function toggleObject(obj_id,arrowSide,changeCookie){
	if (dotoggle){

		if(changeCookie==1){
			NewCookie = $.cookie('toggle_'+obj_id) == 1 ? 0 : 1;
			$.cookie('toggle_'+obj_id,NewCookie,{ path: '/'});
			//alert($.cookie('toggle_'+obj_id+''));
		}

		var adv_img = $('img#Object_'+obj_id+'_Opener').attr('src')
			
		if(adv_img=='/images/arrow_'+arrowSide+'.png')
			adv_img = '/images/arrow_down.png';
		else
			adv_img = '/images/arrow_'+arrowSide+'.png';
				
		$('img#Object_'+obj_id+'_Opener').attr('src',adv_img);
		
		$('div#object_content_'+obj_id+'').toggle();
	
	}
}

function setsort(type) {
    $.cookie('SiteOrder', type, { path: '/' });
    location.reload();
}

function setTypeIds(type,advanced) {
    New_Value = type;
    if ($.cookie('Cur_Type_Ids') == type) { New_Value = null; };
    $.cookie('Cur_Type_Ids', New_Value, { path: '/' });
    
    if (advanced == '1') {
        $('#frm_advanced_search').submit();
    } else {
        location.reload();
    }
}

function playNext(playerId) {
    playNum = playNum + 1;
    if (playNum > totalSongs) { playNum = 0 };
    niftyplayer(playerId).loadAndPlay(songs[playNum]);
}

function playPrev(playerId) {
    playNum = playNum - 1;
    if (playNum < 0) { playNum = totalSongs };
    niftyplayer(playerId).loadAndPlay(songs[playNum]);
}


/*---[ Login Funcs ]---*/

function new_exists_mem(fid) {
    $('#reg_table_' + fid + ' .memReg').toggle();
    newType = $('#reg_table_' + fid + ' #Member_Fname').attr('check_type') == '' ? 'exists' : '';
    $('#reg_table_' + fid + ' #Member_Fname').attr('check_type', newType);
    $('#reg_table_' + fid + ' #Member_Lname').attr('check_type', newType);
    $('#reg_table_' + fid + ' #Member_BirthDate_Day').attr('check_type', newType);
    $('#reg_table_' + fid + ' #Member_BirthDate_Month').attr('check_type', newType);
    $('#reg_table_' + fid + ' #Member_BirthDate_Year').attr('check_type', newType);
    $('#reg_table_' + fid + ' #Member_RePassword').attr('check_type', newType);
    $('#reg_table_' + fid + ' #action').val($('#reg_table_' + fid + ' #action').val() == 'new_mem' ? 'mem_login' : 'new_mem');
}

function passRecall(fid) {
    $('#reg_table_' + fid + ' #forgotPass').toggle();
    $('#reg_table_' + fid + ' #memLogin').toggle();
}

function loginBox(containerID, toggleClass, fid, js, group, noClose, login) {

    $('#' + containerID).html('<center><h2>Loading...</h2></center>');
    
    $.post('/login_box.asp', {
        containerID: containerID,
        toggleClass: toggleClass,
        fid: fid,
        js: js,
        noClose: noClose,
        login: login,    
        group: group   
    },

    function(data) {
        $('#' + containerID).html(data).slideDown();
        }
    );
}

function closeBox(containerID, toggleClass) {
    $('#' + containerID).slideUp();
    if (toggleClass != '') { $('.' + toggleClass).toggle() };
}

function changeUser(redir, js) {  
    theIframe.location.href = '/site_handler.asp?action=logoff&js='+js+'&redir='+redir;
}

function logoff() {
    theIframe.location.href = '/site_handler.asp?action=logoff'
}

/*----------------------*/

function conf(text,url){
	if (confirm(text))
		location.href=url;
}


function SetPage(page_num,links,dir){
	if (page_num == -1)
		if (dir != 1){location.href=('?numofrec=999&'+links)}else{location.href=(links+'/0')}
	else
		if (dir != 1){location.href=('?page='+page_num+'&'+links)}else{location.href=(links+'/'+page_num)}
}


function MaxLength(obj,max){
	if(obj.length>=max){
		alert(max+' chars maximum!');
		event.returnValue = false;
	}
}

function stop_youtube(){
	var cur_id = null;
	$('embed.youtube').each(function(){
		cur_id = $(this).attr('id');
		cur_vid = document.getElementById(cur_id);
		cur_vid.stopVideo();
	});
}

function youtube_volume(num){
	var cur_id = null;
	$('embed.youtube').each(function(){
		cur_id = $(this).attr('id');
		cur_vid = document.getElementById(cur_id);
		cur_vid.setVolume(num);
	});
}

function InputText(id,text) {
    if ($('#' + id).val() == '' || $('#' + id).val() == null) 
    {
        $('#' + id).val(text).addClass('text-in-input')
    };
    
    $('#' + id).focus(function() {
        if ($('#' + id).val() == text || $('#' + id).val() == '' || $('#' + id).val() == null) 
        {
            $(this).val('').removeClass('text-in-input');
        }
    }).blur(function() {
        if ($('#' + id).val() == '' || $('#' + id).val() == null) 
        {
            $(this).val(text).addClass('text-in-input');
        }
    });
}

function showImage(src, width, height) {
    var w = window.open(src, '_blank', 'scrollbars=no,resizable=1,width=' + width + ',height=' + height);
    w.focus();
    return false;
}

//---[ Rank Functions ]----------------------------------------------------------------------------------------------------
function vote(formObj){
	
	var el_collection = formObj.VOTE_Poll_Id
	
	var foundCheck = false
			
	for (c=0;c<el_collection.length;c++)
		if (el_collection[c].checked)
			foundCheck = true

	if(foundCheck)
		formObj.submit();
	else
		alert(formObj.attributes["badMsg"].nodeValue)
}

function RankOnOver(id,pointer){
	for(r=1;r<=pointer;r++){
		document.getElementById('star_'+r+'_'+id).src='/unique/images/star_over.gif'
	}
}

function RankOnOut(id,pointer,rank){
	for(r=1;r<=pointer;r++){
		if(r<=rank)
			document.getElementById('star_'+r+'_'+id).src='/unique/images/star_locked.gif'
		else
			document.getElementById('star_'+r+'_'+id).src='/unique/images/star_blank.gif'
	}
}

function RankRec(id,rank){
	RankDisallow(id);
	theIframe.location.href='/site_handler.asp?rid='+id+'&rank='+rank;
}

function RankDisallow(id){
	for(r=1;r<6;r++){
		curStarObj = document.getElementById('star_'+r+'_'+id);
		curStarObj.onmouseout=null;
		curStarObj.onmouseover=null;
		curStarObj.onclick=null;
		curStarObj.style.cursor='default';
	}
}
//-------------------------------------------------------------------------------------------------------------
